|
@@ -16,7 +16,7 @@ Daniel-Constantin Mierla
|
|
|
|
|
|
<[email protected]>
|
|
|
|
|
|
- Copyright © 2003, 2004 FhG FOKUS
|
|
|
+ Copyright © 2003, 2004 FhG FOKUS
|
|
|
__________________________________________________________________
|
|
|
|
|
|
Table of Contents
|
|
@@ -44,7 +44,7 @@ Daniel-Constantin Mierla
|
|
|
|
|
|
5. Installation and Running
|
|
|
|
|
|
- 5.1. Using dbtext with basic Kamailio configuration
|
|
|
+ 5.1. Using db_text with a basic Kamailio configuration
|
|
|
|
|
|
2. Developer Guide
|
|
|
|
|
@@ -85,7 +85,7 @@ Chapter 1. Admin Guide
|
|
|
|
|
|
5. Installation and Running
|
|
|
|
|
|
- 5.1. Using dbtext with basic Kamailio configuration
|
|
|
+ 5.1. Using db_text with a basic Kamailio configuration
|
|
|
|
|
|
1. Overview
|
|
|
|
|
@@ -99,41 +99,43 @@ Chapter 1. Admin Guide
|
|
|
|
|
|
The module is meant for use in demos or small devices that do not
|
|
|
support other DB modules. It keeps everything in memory and if you deal
|
|
|
- with large amount of data you may run quickly out of memory. Also, it
|
|
|
- has not implemented all standard database facilities (like order by),
|
|
|
- it includes minimal functionality to work properly (who knows ?!?) with
|
|
|
+ with large amount of data you may run out of memory quickly. Also, it
|
|
|
+ does not implement all standard database facilities (like order by), it
|
|
|
+ includes minimal functionality to work properly (who knows ?!?) with
|
|
|
Kamailio.
|
|
|
|
|
|
NOTE: the timestamp is printed in an integer value from time_t
|
|
|
structure. If you use it in a system that cannot do this conversion, it
|
|
|
will fail (support for such situation is in to-do list).
|
|
|
|
|
|
- NOTE: even when is in non-caching mode, the module does not write back
|
|
|
- to hard drive after changes. In this mode, the module checks if the
|
|
|
- corresponding file on disk has changed, and reloads it. The write on
|
|
|
- disk happens at openser shut down.
|
|
|
+ NOTE: even when db_text is in non-caching mode, the module does not
|
|
|
+ write back to hard drive after changes. In this mode, the module checks
|
|
|
+ if the corresponding file on disk has changed, and reloads it. The
|
|
|
+ write to disk happens at Kamailio shut down.
|
|
|
|
|
|
1.1. Design of dbtext engine
|
|
|
|
|
|
The dbtext database system architecture:
|
|
|
- * a database is represented by a directory in the local file system.
|
|
|
+ * A database is represented by a directory in the local file system.
|
|
|
NOTE: when you use dbtext in Kamailio, the database URL for modules
|
|
|
must be the path to the directory where the table-files are
|
|
|
- located, prefixed by “text://�, e.g., “text:///var/dbtext/ser�. If
|
|
|
- there is no “/� after “text://� then “CFG_DIR/� is inserted at the
|
|
|
+ located, prefixed by "text://", e.g., "text:///var/dbtext/ser". If
|
|
|
+ there is no "/" after "text://" then "CFG_DIR/" is inserted at the
|
|
|
beginning of the database path. So, either you provide an absolute
|
|
|
- path to database directory or a relative one to “CFG_DIR�
|
|
|
+ path to database directory or a relative one to "CFG_DIR"
|
|
|
directory.
|
|
|
- * a table is represented by a text file inside database directory.
|
|
|
+ Do not forget that all databases in Kamailio needs the "version"
|
|
|
+ table.
|
|
|
+ * A table is represented by a text file inside database directory.
|
|
|
|
|
|
1.2. Internal format of a dbtext table
|
|
|
|
|
|
- First line is the definition of the columns. Each column must be
|
|
|
- declared as follows:
|
|
|
+ The first line is the definition of the columns. Each column must be
|
|
|
+ declared in the following format:
|
|
|
* the name of column must not include white spaces.
|
|
|
* the format of a column definition is: name(type,attr).
|
|
|
* between two column definitions must be a white space, e.g.,
|
|
|
- “first_name(str) last_name(str)�.
|
|
|
+ "first_name(str) last_name(str)".
|
|
|
* the type of a column can be:
|
|
|
+ int - integer numbers.
|
|
|
+ double - real numbers with two decimals.
|
|
@@ -145,11 +147,11 @@ Chapter 1. Admin Guide
|
|
|
+ null - accept null values in column fields.
|
|
|
+ if no attribute is set, the fields of the column cannot have
|
|
|
null value.
|
|
|
- * each other line is a row with data. The line ends with “\n�.
|
|
|
- * the fields are separated by “:�.
|
|
|
+ * each other line is a row with data. The line ends with "\n".
|
|
|
+ * the fields are separated by ":".
|
|
|
* no value between two ':' (or between ':' and start/end of a row)
|
|
|
- means “null� value.
|
|
|
- * next characters must be escaped in strings: “\n�, “\r�, “\t�, “:�.
|
|
|
+ means "null" value.
|
|
|
+ * next characters must be escaped in strings: "\n", "\r", "\t", ":".
|
|
|
* 0 -- the zero value must be escaped too.
|
|
|
|
|
|
Example 1.1. Sample of a dbtext table
|
|
@@ -173,7 +175,7 @@ suser:supasswd:xxx:alpha.org:xxx
|
|
|
|
|
|
1.3. Existing limitations
|
|
|
|
|
|
- This database interface don't support the data insertion with default
|
|
|
+ This database interface does not support data insertion with default
|
|
|
values. All such values specified in the database template are ignored.
|
|
|
So its advisable to specify all data for a column at insertion
|
|
|
operations.
|
|
@@ -185,12 +187,12 @@ suser:supasswd:xxx:alpha.org:xxx
|
|
|
|
|
|
2.1. Kamailio modules
|
|
|
|
|
|
- The next modules must be loaded before this module:
|
|
|
+ These modules must be loaded before this module:
|
|
|
* none.
|
|
|
|
|
|
2.2. External libraries or applications
|
|
|
|
|
|
- The next libraries or applications must be installed before running
|
|
|
+ These libraries or applications must be installed before running
|
|
|
Kamailio with this module:
|
|
|
* none.
|
|
|
|
|
@@ -205,9 +207,9 @@ suser:supasswd:xxx:alpha.org:xxx
|
|
|
Set caching mode (0) or non-caching mode (1). In caching mode, data is
|
|
|
loaded at startup. In non-caching mode, the module check every time a
|
|
|
table is requested whether the corresponding file on disk has changed,
|
|
|
- and if yes, will re-load table from file.
|
|
|
+ and if yes, will re-load the table from file.
|
|
|
|
|
|
- Default value is “0�.
|
|
|
+ Default value is "0".
|
|
|
|
|
|
Example 1.4. Set db_mode parameter
|
|
|
...
|
|
@@ -220,7 +222,7 @@ modparam("db_text", "db_mode", 1)
|
|
|
|
|
|
4.1. db_text.dump
|
|
|
|
|
|
- Write back to hard drive modified tables.
|
|
|
+ Write back to hard drive all modified tables.
|
|
|
|
|
|
Name: db_text.dump
|
|
|
|
|
@@ -231,16 +233,16 @@ modparam("db_text", "db_mode", 1)
|
|
|
|
|
|
5. Installation and Running
|
|
|
|
|
|
- 5.1. Using dbtext with basic Kamailio configuration
|
|
|
+ 5.1. Using db_text with a basic Kamailio configuration
|
|
|
|
|
|
Compile the module and load it instead of mysql or other DB modules.
|
|
|
|
|
|
REMINDER: when you use text in Kamailio, the database URL for modules
|
|
|
must be the path to the directory where the table-files are located,
|
|
|
- prefixed by “text://�, e.g., “text:///var/dbtext/ser�. If there is no
|
|
|
- “/� after “text://� then “CFG_DIR/� is inserted at the beginning of the
|
|
|
+ prefixed by "text://", e.g., "text:///var/dbtext/ser". If there is no
|
|
|
+ "/" after "text://" then "CFG_DIR/" is inserted at the beginning of the
|
|
|
database path. So, either you provide an absolute path to database
|
|
|
- directory or a relative one to “CFG_DIR� directory.
|
|
|
+ directory or a relative one to "CFG_DIR" directory.
|
|
|
|
|
|
Example 1.5. Load the dbtext module
|
|
|
...
|
|
@@ -249,12 +251,13 @@ loadmodule "/path/to/kamailio/modules_k/db_text.so"
|
|
|
modparam("module_name", "db_url", "text:///path/to/dbtext/database")
|
|
|
...
|
|
|
|
|
|
-5.1. Using dbtext with basic Kamailio configuration
|
|
|
+5.1. Using db_text with a basic Kamailio configuration
|
|
|
|
|
|
- Here are the definitions for most important table as well as a basic
|
|
|
- configuration file to use dbtext with Kamailio. The table structures
|
|
|
- may change in time and you will have to adjust next examples. These are
|
|
|
- know to work with upcoming Kamailio v0.9.x
|
|
|
+ Here are definitions for the most important tables as well as a basic
|
|
|
+ configuration file to use db_text with Kamailio. The table structures
|
|
|
+ may change in time and you will have to adjust these examples. Check
|
|
|
+ the source code directory "utils/kamctl/dbtxt/kamailio" for current
|
|
|
+ definitions.
|
|
|
|
|
|
You have to populate the table 'subscriber' by hand with user profiles
|
|
|
in order to have authentication. To use with the given configuration
|
|
@@ -262,17 +265,17 @@ modparam("module_name", "db_url", "text:///path/to/dbtext/database")
|
|
|
|
|
|
Example 1.6. Definition of 'subscriber' table (one line)
|
|
|
...
|
|
|
-username(str) domain(str) password(str) first_name(str) last_name(str) phone(st
|
|
|
-r) email_address(str) datetime_created(int) datetime_modified(int) confirmation
|
|
|
-(str) flag(str) sendnotification(str) greeting(str) ha1(str) ha1b(str) perms(st
|
|
|
-r) allow_find(str) timezone(str,null) rpid(str,null)
|
|
|
+username(str) domain(str) password(str) first_name(str) last_name(str) phone(str
|
|
|
+) email_address(str) datetime_created(int) datetime_modified(int) confirmation(s
|
|
|
+tr) flag(str) sendnotification(str) greeting(str) ha1(str) ha1b(str) perms(str)
|
|
|
+allow_find(str) timezone(str,null) rpid(str,null)
|
|
|
...
|
|
|
|
|
|
Example 1.7. Definition of 'location' and 'aliases' tables (one line)
|
|
|
...
|
|
|
-username(str) domain(str,null) contact(str,null) received(str) expires(int,null
|
|
|
-) q(double,null) callid(str,null) cseq(int,null) last_modified(str) flags(int)
|
|
|
-user_agent(str) socket(str)
|
|
|
+username(str) domain(str,null) contact(str,null) received(str) expires(int,null)
|
|
|
+ q(double,null) callid(str,null) cseq(int,null) last_modified(str) flags(int) us
|
|
|
+er_agent(str) socket(str)
|
|
|
...
|
|
|
|
|
|
Example 1.8. Definition of 'version' table and sample records
|