README 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. 1. Usrloc Module
  2. Jan Janak
  3. FhG FOKUS
  4. Copyright © 2003 FhG FOKUS
  5. __________________________________________________________________
  6. 1.1. Overview
  7. 1.2. Dependencies
  8. 1.3. Parameters
  9. 1.3.1. user_column (string)
  10. 1.3.2. contact_column (string)
  11. 1.3.3. expires_column (string)
  12. 1.3.4. q_column (string)
  13. 1.3.5. callid_column (string)
  14. 1.3.6. cseq_column (string)
  15. 1.3.7. method_column (string)
  16. 1.3.8. user_agent_column (string)
  17. 1.3.9. received_column (string)
  18. 1.3.10. db_url (string)
  19. 1.3.11. timer_interval (integer)
  20. 1.3.12. db_mode (integer)
  21. 1.4. Usrloc Module API
  22. 1.4.1. ul_register_domain(name)
  23. 1.4.2. ul_insert_urecord(domain, aor, rec)
  24. 1.4.3. ul_delete_urecord(domain, aor)
  25. 1.4.4. ul_get_urecord(domain, aor)
  26. 1.4.5. ul_lock_udomain(domain)
  27. 1.4.6. ul_unlock_udomain(domain)
  28. 1.4.7. ul_release_urecord(record)
  29. 1.4.8. ul_insert_ucontact(record, contact, expires, q, callid,
  30. cseq, flags, cont, ua)
  31. 1.4.9. ul_delete_ucontact(record, contact)
  32. 1.4.10. ul_get_ucontact(record, contact)
  33. 1.4.11. ul_get_all_ucontacts(buf, len, flags)
  34. 1.4.12. ul_update_ucontact(contact, expires, q, callid, cseq, set,
  35. res, ua)
  36. 1.1. Overview
  37. User location module. The module keeps a user location table and
  38. provides access to the table to other modules. The module exports no
  39. functions that could be used directly from scripts.
  40. 1.2. Dependencies
  41. The following modules must be loaded before this module:
  42. * Optionally a database module.
  43. 1.3. Parameters
  44. 1.3.1. user_column (string)
  45. Name of column containing usernames.
  46. Default value is "username".
  47. Example 1. Set user_column parameter
  48. ...
  49. modparam("usrloc", "user_column", "username")
  50. ...
  51. 1.3.2. contact_column (string)
  52. Name of column containing contacts.
  53. Default value is "contact".
  54. Example 2. Set contact_column parameter
  55. ...
  56. modparam("usrloc", "contact_column", "contact")
  57. ...
  58. 1.3.3. expires_column (string)
  59. Name of column containing expires value.
  60. Default value is "expires".
  61. Example 3. Set expires_column parameter
  62. ...
  63. modparam("usrloc", "expires_column", "expires")
  64. ...
  65. 1.3.4. q_column (string)
  66. Name of column containing q values.
  67. Default value is "q".
  68. Example 4. Set q_column parameter
  69. ...
  70. modparam("usrloc", "q_column", "q")
  71. ...
  72. 1.3.5. callid_column (string)
  73. Name of column containing callid values.
  74. Default value is "callid".
  75. Example 5. Set callid_column parameter
  76. ...
  77. modparam("usrloc", "callid_column", "callid")
  78. ...
  79. 1.3.6. cseq_column (string)
  80. Name of column containing cseq numbers.
  81. Default value is "cseq".
  82. Example 6. Set cseq_column parameter
  83. ...
  84. modparam("usrloc", "cseq_column", "cseq")
  85. ...
  86. 1.3.7. method_column (string)
  87. Name of column containing supported methods.
  88. Default value is "method".
  89. Example 7. Set method_column parameter
  90. ...
  91. modparam("usrloc", "method_column", "method")
  92. ...
  93. 1.3.8. user_agent_column (string)
  94. Name of column containing user-agent values.
  95. Default value is "user_agent".
  96. Example 8. Set user_agent_column parameter
  97. ...
  98. modparam("usrloc", "user_agent_column", "user_agent")
  99. ...
  100. 1.3.9. received_column (string)
  101. Name of column containing the source IP, port, and protocol from the
  102. REGISTER message.
  103. Default value is "received".
  104. Example 9. Set received_column parameter
  105. ...
  106. modparam("usrloc", "received_column", "received")
  107. ...
  108. 1.3.10. db_url (string)
  109. URL of the database that should be used.
  110. Default value is "mysql://ser:heslo@localhost/ser".
  111. Example 10. Set db_url parameter
  112. ...
  113. modparam("usrloc", "db_url", "mysql://username:password@localhost/ser")
  114. ...
  115. 1.3.11. timer_interval (integer)
  116. Number of seconds between two timer runs. The module uses timer to
  117. delete expired contacts, synchronize with database and other tasks,
  118. that need to be run periodically.
  119. Default value is 60.
  120. Example 11. Set timer_interval parameter
  121. ...
  122. modparam("usrloc", "timer_interval", 120)
  123. ...
  124. 1.3.12. db_mode (integer)
  125. The usrloc module can utilize database for persistent contact storage.
  126. If you use database, your contacts will survive machine restarts or SW
  127. crashes. The disadvantage is that accessing database can be very time
  128. consuming. Therefore, usrloc module implements four database accessing
  129. modes:
  130. * 0 - This disables database completely. Only memory will be used.
  131. Contacts will not survive restart. Use this value if you need a
  132. really fast usrloc and contact persistence is not necessary or is
  133. provided by other means.
  134. * 1 - Write-Through scheme. All changes to usrloc are immediately
  135. reflected in database too. This is very slow, but very reliable.
  136. Use this scheme if speed is not your priority but need to make sure
  137. that no registered contacts will be lost during crash or reboot.
  138. * 2 - Write-Back scheme. This is a combination of previous two
  139. schemes. All changes are made to memory and database
  140. synchronization is done in the timer. The timer deletes all expired
  141. contacts and flushes all modified or new contacts to database. Use
  142. this scheme if you encounter high-load peaks and want them to
  143. process as fast as possible. The mode will not help at all if the
  144. load is high all the time. Also, latency of this mode is much lower
  145. than latency of mode 1, but slightly higher than latency of mode 0.
  146. * 3 - Read-Only scheme. Disables commits to database. Upon start
  147. contacts are read from the database but changes are not written.
  148. Contacts will thus not survive a restart unless taken care of
  149. otherwise. Use this if you need the benefits of mode 0 with a
  150. databases backed preloading feature. Attention: There is a slight
  151. window where updated contacts might not make it into memory while
  152. reading and parsing contacts from the database before going into
  153. full production mode.
  154. Warning
  155. In case of crash or restart contacts that are in memory only and
  156. haven't been flushed yet will get lost. If you want minimize the risk,
  157. use shorter timer interval.
  158. Default value is 0.
  159. Example 12. Set db_mode parameter
  160. ...
  161. modparam("usrloc", "db_mode", 2)
  162. ...
  163. 1.4. Usrloc Module API
  164. 1.4.1. ul_register_domain(name)
  165. The function registers a new domain. Domain is just another name for
  166. table used in registrar. The function is called from fixups in
  167. registrar. It gets name of the domain as a parameter and returns
  168. pointer to a new domain structure. The fixup than 'fixes' the parameter
  169. in registrar so that it will pass the pointer instead of the name every
  170. time save() or lookup() is called. Some usrloc functions get the
  171. pointer as parameter when called. For more details see implementation
  172. of save function in registrar.
  173. Meaning of the parameters is as follows:
  174. * const char* name - Name of the domain (also called table) to be
  175. registered.
  176. 1.4.2. ul_insert_urecord(domain, aor, rec)
  177. The function creates a new record structure and inserts it in the
  178. specified domain. The record is structure that contains all the
  179. contacts for belonging to the specified username.
  180. Meaning of the parameters is as follows:
  181. * udomain_t* domain - Pointer to domain returned by
  182. ul_register_udomain.
  183. * str* aor - Address of Record (aka username) of the new record (at
  184. this time the record will contain no contacts yet).
  185. * urecord_t** rec - The newly created record structure.
  186. 1.4.3. ul_delete_urecord(domain, aor)
  187. The function deletes all the contacts bound with the given Address Of
  188. Record.
  189. Meaning of the parameters is as follows:
  190. * udomain_t* domain - Pointer to domain returned by
  191. ul_register_udomain.
  192. * str* aor - Address of record (aka username) of the record, that
  193. should be deleted.
  194. 1.4.4. ul_get_urecord(domain, aor)
  195. The function returns pointer to record with given Address of Record.
  196. Meaning of the parameters is as follows:
  197. * udomain_t* domain - Pointer to domain returned by
  198. ul_register_udomain.
  199. * str* aor - Address of Record of request record.
  200. 1.4.5. ul_lock_udomain(domain)
  201. The function lock the specified domain, it means, that no other
  202. processes will be able to access during the time. This prevents race
  203. conditions. Scope of the lock is the specified domain, that means, that
  204. multiple domain can be accessed simultaneously, they don't block each
  205. other.
  206. Meaning of the parameters is as follows:
  207. * udomain_t* domain - Domain to be locked.
  208. 1.4.6. ul_unlock_udomain(domain)
  209. Unlock the specified domain previously locked by ul_lock_udomain.
  210. Meaning of the parameters is as follows:
  211. * udomain_t* domain - Domain to be unlocked.
  212. 1.4.7. ul_release_urecord(record)
  213. Do some sanity checks - if all contacts have been removed, delete the
  214. entire record structure.
  215. Meaning of the parameters is as follows:
  216. * urecord_t* record - Record to be released.
  217. 1.4.8. ul_insert_ucontact(record, contact, expires, q, callid, cseq, flags,
  218. cont, ua)
  219. The function inserts a new contact in the given record with specified
  220. parameters.
  221. Meaning of the parameters is as follows:
  222. * urecord_t* record - Record in which the contact should be inserted.
  223. * str* contact - Contact URI.
  224. * time_t expires - Expires of the contact in absolute value.
  225. * float q - q value of the contact.
  226. * str* callid - Call-ID of the REGISTER message that contained the
  227. contact.
  228. * int cseq - CSeq of the REGISTER message that contained the contact.
  229. * unsigned int flags - Flags to be set.
  230. * ucontact_t* cont - Pointer to newly created structure.
  231. * str* ua - User-Agent of the REGISTER message that contained the
  232. contact.
  233. 1.4.9. ul_delete_ucontact(record, contact)
  234. The function deletes given contact from record.
  235. Meaning of the parameters is as follows:
  236. * urecord_t* record - Record from which the contact should be
  237. removed.
  238. * ucontact_t* contact - Contact to be deleted.
  239. 1.4.10. ul_get_ucontact(record, contact)
  240. The function tries to find contact with given Contact URI and returns
  241. pointer to structure representing the contact.
  242. Meaning of the parameters is as follows:
  243. * urecord_t* record - Record to be searched for the contact.
  244. * str_t* contact - URI of the request contact.
  245. 1.4.11. ul_get_all_ucontacts(buf, len, flags)
  246. The function retrieves all contacts of all registered users and returns
  247. them in the caller-supplied buffer. If the buffer is too small, the
  248. function returns positive value indicating how much additional space
  249. would be necessary to accommodate all of them. Please note that the
  250. positive return value should be used only as a "hint", as there is no
  251. guarantee that during the time between two subsequent calls number of
  252. registered contacts will remain the same.
  253. If flag parameter is set to non-zero value then only contacts that have
  254. the specified flags set will be returned. It is, for example, possible
  255. to list only contacts that are behind NAT.
  256. Meaning of the parameters is as follows:
  257. * void* buf - Buffer for returning contacts.
  258. * int len - Length of the buffer.
  259. * unsigned int flags - Flags that must be set.
  260. 1.4.12. ul_update_ucontact(contact, expires, q, callid, cseq, set, res, ua)
  261. The function updates contact with new values.
  262. Meaning of the parameters is as follows:
  263. * ucontact_t* contact - Contact URI.
  264. * time_t expires - Expires of the contact in absolute value.
  265. * float q - q value of the contact.
  266. * str* callid - Call-ID of the REGISTER message that contained the
  267. contact.
  268. * int cseq - CSeq of the REGISTER message that contained the contact.
  269. * unsigned int set - OR value of flags to be set.
  270. * unsigned int res - OR value of flags to be reset.
  271. * str* ua - User-Agent of the REGISTER message that contained the
  272. contact.