README 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. unixodbc Module
  2. Marco Lorrai
  3. abbeynet.it
  4. Edited by
  5. Marco Lorrai
  6. Copyright © 2005, 2006 Marco Lorrai
  7. __________________________________________________________________
  8. Table of Contents
  9. 1. Admin Guide
  10. 1. Overview
  11. 2. Dependencies
  12. 2.1. Kamailio Modules
  13. 2.2. External Libraries or Applications
  14. 3. Parameters
  15. 3.1. ping_interval (int)
  16. 3.2. auto_reconnect (int)
  17. 3.3. use_escape_common (int)
  18. 4. Functions
  19. 5. Installation and Running
  20. 5.1. Installing
  21. 5.2. Configuring and Running
  22. 2. Developer Guide
  23. List of Examples
  24. 1.1. Set the “ping_interval” parameter
  25. 1.2. Set the “auto_reconnect” parameter
  26. 1.3. Set the “use_escape_common” parameter
  27. Chapter 1. Admin Guide
  28. Table of Contents
  29. 1. Overview
  30. 2. Dependencies
  31. 2.1. Kamailio Modules
  32. 2.2. External Libraries or Applications
  33. 3. Parameters
  34. 3.1. ping_interval (int)
  35. 3.2. auto_reconnect (int)
  36. 3.3. use_escape_common (int)
  37. 4. Functions
  38. 5. Installation and Running
  39. 5.1. Installing
  40. 5.2. Configuring and Running
  41. 1. Overview
  42. This module allows to use the unixodbc package with Kamailio. It have
  43. been tested with mysql and the odbc connector, but it should work also
  44. with other database. The auth_db module works.
  45. For more information, see the http://www.unixodbc.org/ project web
  46. page.
  47. To see what DB engines can be used via unixodbc, look at
  48. http://www.unixodbc.org/drivers.html.
  49. 2. Dependencies
  50. 2.1. Kamailio Modules
  51. 2.2. External Libraries or Applications
  52. 2.1. Kamailio Modules
  53. The following modules must be loaded before this module:
  54. * No dependencies on other Kamailio modules.
  55. 2.2. External Libraries or Applications
  56. The following libraries or applications must be installed before
  57. running Kamailio with this module loaded:
  58. * None.
  59. 3. Parameters
  60. 3.1. ping_interval (int)
  61. 3.2. auto_reconnect (int)
  62. 3.3. use_escape_common (int)
  63. 3.1. ping_interval (int)
  64. Sets the ping time interval.
  65. Default value is “300” seconds.
  66. Example 1.1. Set the “ping_interval” parameter
  67. ...
  68. modparam("db_unixodbc", "ping_interval", 600)
  69. ...
  70. 3.2. auto_reconnect (int)
  71. Turns on or off the auto_reconnect mode.
  72. Default value is “1”, this means it is enabled.
  73. Example 1.2. Set the “auto_reconnect” parameter
  74. ...
  75. modparam("db_unixodbc", "auto_reconnect", 0)
  76. ...
  77. 3.3. use_escape_common (int)
  78. Escape values in query using internal escape_common() function. It
  79. escapes single quote ''', double quote '"', backslash '\', and NULL
  80. characters.
  81. You should enable this parameter if you know that the ODBC driver
  82. considers the above characters as special (for marking begin and end of
  83. a value, escape other characters ...). It prevents against SQL
  84. injection.
  85. Default value is “0” (0 = disabled; 1 = enabled).
  86. Example 1.3. Set the “use_escape_common” parameter
  87. ...
  88. modparam("db_unixodbc", "use_escape_common", 1)
  89. ...
  90. 4. Functions
  91. NONE
  92. 5. Installation and Running
  93. 5.1. Installing
  94. 5.2. Configuring and Running
  95. 5.1. Installing
  96. Prerequirement: you should first install unixodbc (or another program
  97. that implements the odbc standard, such iodbc), your database, and the
  98. right connector. Set the DSN in the odbc.ini file and the connector
  99. drivers in the odbcinst.ini file.
  100. 5.2. Configuring and Running
  101. In the openser.conf file, add the line:
  102. ....
  103. loadmodule "/usr/local/lib/kamailio/modules/db_unixodbc.so"
  104. ....
  105. You should also uncomment this:
  106. ....
  107. loadmodule "/usr/local/lib/kamailio/modules/auth.so"
  108. loadmodule "/usr/local/lib/kamailio/modules/auth_db.so"
  109. modparam("usrloc", "db_mode", 2)
  110. modparam("auth_db", "calculate_ha1", yes)
  111. modparam("auth_db", "password_column", "password")
  112. ....
  113. and setting the DSN specified in the odbc.ini, inserting this with the
  114. url adding this line:
  115. ....
  116. modparam("usrloc|auth_db", "db_url",
  117. "unixodbc://openser:openserrw@localhost/my_dsn")
  118. ....
  119. replacing my_dsn with the correct value.
  120. HINT: if unixodbc don't want to connect to mysql server, try restarting
  121. mysql server with:
  122. shell>safe_mysqld --user=mysql --socket=/var/lib/mysql/mysql.sock
  123. The connector search the socket in /var/lib/mysql/mysql.sock and not in
  124. /tmp/mysql.sock
  125. Chapter 2. Developer Guide
  126. The module implements the Kamailio DB API, in order to be used by other
  127. modules.