README 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. 1. Acc Module
  2. Jiri Kuthan
  3. iptel.org
  4. <[email protected]>
  5. Copyright © 2002, 2003 FhG FOKUS
  6. __________________________________________________________________
  7. 1.1. Overview
  8. 1.2. Dependencies
  9. 1.3. Parameters
  10. 1.3.1. log_level (integer)
  11. 1.3.2. log_fmt (string)
  12. 1.3.3. early_media (integer)
  13. 1.3.4. failed_transactions (integer)
  14. 1.3.5. log_flag (integer)
  15. 1.3.6. log_missed_flag (integer)
  16. 1.3.7. report_ack (integer)
  17. 1.3.8. report_cancels (integer)
  18. 1.3.9. radius_config (string)
  19. 1.3.10. service_type (integer)
  20. 1.3.11. radius_flag (integer)
  21. 1.3.12. radius_missed_flag (integer)
  22. 1.3.13. db_url (string)
  23. 1.3.14. db_flag (integer)
  24. 1.3.15. db_missed_flag (integer)
  25. 1.3.16. diameter_flag (integer)
  26. 1.3.17. diameter_missed_flag (integer)
  27. 1.3.18. diameter_client_host (string)
  28. 1.3.19. diameter_client_port (int)
  29. 1.4. Functions
  30. 1.4.1. acc_log_request(comment)
  31. 1.4.2. acc_db_request(comment, table)
  32. 1.4.3. acc_rad_request(comment)
  33. 1.4.4. acc_diam_request(comment)
  34. 1.1. Overview
  35. acc module is used to report on transactions to syslog, SQL and RADIUS.
  36. To report on a transaction using syslog, use "setflag" to mark a
  37. transaction you are interested in with a flag, load accounting module
  38. and set its "log_flag" to the same flag number. The acc module will
  39. then report on completed transaction to syslog. A typical usage of the
  40. module takes no acc-specific script command -- the functionality binds
  41. invisibly through transaction processing. Script writers just need to
  42. mark the transaction for accounting with proper setflag.
  43. What is printed depends on module's "log_fmt" parameter. It's a string
  44. with characters specifying which parts of request should be printed:
  45. * c = Call-Id
  46. * d = To tag (Dst)
  47. * f = From
  48. * i = Inbound Request-URI
  49. * m = Method
  50. * o = Outbound Request-URI
  51. * r = fRom
  52. * s = Status
  53. * t = To
  54. * u = digest Username
  55. * p = username Part of inbound Request-URI
  56. If a value is not present in request, "n/a" is accounted instead.
  57. Note
  58. * A single INVITE may produce multiple accounting reports -- that's
  59. due to SIP forking feature
  60. * Subsequent ACKs and other requests do not hit the server and can't
  61. be accounted unless record-routing is enforced. The ACKs assert
  62. very little useful information anyway and reporting on INVITE's 200
  63. makes most accounting scenarios happy.
  64. * There is no session accounting -- ser maintains no sessions. If one
  65. needs to correlate INVITEs with BYEs for example for purpose of
  66. billing, then it is better done in the entity which collects
  67. accounting information. Otherwise, SIP server would have to become
  68. sessions-stateful, which would very badly impact its scalability.
  69. * If a UA fails in middle of conversation, a proxy will never learn
  70. it. In general, a better practice is to account from an end-device
  71. (such as PSTN gateway), which best knows about call status
  72. (including media status and PSTN status in case of the gateway).
  73. Support for SQL and RADIUS works analogously. You need to enable it by
  74. recompiling the module with properly set defines. Uncomment the SQL_ACC
  75. and RAD_ACC lines in modules/acc/Makefile. To compile SQL support, you
  76. need to have mysqlclient package on your system. To compile RADIUS
  77. support, you need to have radiusclient installed on your system
  78. (version 0.5.0 or higher is required) which is available from
  79. http://developer.berlios.de/projects/radiusclient-ng/. The radius
  80. client needs to be configured properly. To do so, use the template in
  81. sip_router/etc/radiusclient.conf and make sure that module's
  82. radius_config parameter points to its location. Uses along with
  83. FreeRADIUS and Radiator servers have been reported to us.
  84. Both mysql and radius libraries must be dynamically linkable. You need
  85. to configure your OS so that SER, when started, will find them.
  86. Typically, you do so by manipulating LD_LIBRARY_PATH environment
  87. variable or configuring ld.so.
  88. Example 1. General Example
  89. loadmodule "modules/acc/acc.so"
  90. modparam("acc", "log_level", 1)
  91. modparam("acc", "log_flag", 1)
  92. if (uri=~"sip:+49") /* calls to Germany */ {
  93. if (!proxy_authorize("iptel.org" /* realm */,
  94. "subscriber" /* table name */)) {
  95. proxy_challenge("iptel.org" /* realm */, "0" /* no qop */ );
  96. break;
  97. }
  98. if (method=="INVITE" & !check_from()) {
  99. log("from!=digest\n");
  100. sl_send_reply("403","Forbidden");
  101. break;
  102. }
  103. setflag(1); /* set for accounting (the same value as in log_flag!)
  104. t_relay(); /* enter stateful mode now */
  105. };
  106. 1.2. Dependencies
  107. The module depends on the following modules (in the other words the
  108. listed modules must be loaded before this module):
  109. * tm. Transaction Manager
  110. * A database module (mysql,postgres,dbtext). If compiled with
  111. database support.
  112. 1.3. Parameters
  113. 1.3.1. log_level (integer)
  114. Log level at which accounting messages are issued to syslog.
  115. Default value is L_NOTICE.
  116. Example 2. log_level example
  117. modparam("acc", "log_level", 2) # Set log_level to 2
  118. 1.3.2. log_fmt (string)
  119. Defines what parts of header fields will be printed to syslog, see
  120. "overview" for list of accepted values.
  121. Default value is "miocfs".
  122. Example 3. log_fmt example
  123. modparam("acc", "log_fmt", "mfs")
  124. 1.3.3. early_media (integer)
  125. Should be early media (183) accounted too ?
  126. Default value is 0 (no).
  127. Example 4. early_media example
  128. modparam("acc", "early_media", 1)
  129. 1.3.4. failed_transactions (integer)
  130. This parameter controls whether failed transactions (with final reply
  131. >= 300) should be accounted too.
  132. Default value is 0 (no).
  133. Example 5. failed_transactions example
  134. modparam("acc", "failed_transactions", 1)
  135. 1.3.5. log_flag (integer)
  136. Request flag which needs to be set to account a transaction.
  137. Default value is 1.
  138. Example 6. log_flag example
  139. modparam("acc", "log_flag", 2)
  140. 1.3.6. log_missed_flag (integer)
  141. Request flag which needs to be set to account missed calls.
  142. Default value is 2.
  143. Example 7. log_missed_flag example
  144. modparam("acc", "log_missed_flag", 3)
  145. 1.3.7. report_ack (integer)
  146. Shall acc attempt to account e2e ACKs too ? Note that this is really
  147. only an attempt, as e2e ACKs may take a different path (unless RR
  148. enabled) and mismatch original INVITE (e2e ACKs are a separate
  149. transaction).
  150. Default value is 1 (yes).
  151. Example 8. report_ack example
  152. modparam("acc", "report_ack", 0)
  153. 1.3.8. report_cancels (integer)
  154. By default, CANCEL reporting is disabled -- most accounting
  155. applications are happy to see INVITE's cancellation status. Turn on if
  156. you explicitly want to account CANCEL transactions.
  157. Default value is 0 (no).
  158. Example 9. report_cancels example
  159. modparam("acc", "report_cancels", 1)
  160. 1.3.9. radius_config (string)
  161. This parameter is radius specific. Path to radius client configuration
  162. file, set the referred config file correctly and specify there address
  163. of server, shared secret (should equal that in
  164. /usr/local/etc/raddb/clients for freeRadius servers) and dictionary,
  165. see etc for an example of config file and dictionary.
  166. Default value is “/usr/local/etc/radiusclient/radiusclient.conf”.
  167. Example 10. radius_config example
  168. modparam("acc", "radius_config", "/etc/radiusclient/radiusclient.conf")
  169. 1.3.10. service_type (integer)
  170. Radius service type used for accounting.
  171. Default value is 15 (SIP).
  172. Example 11. service_type example
  173. modparam("acc", "service_type", 16)
  174. 1.3.11. radius_flag (integer)
  175. Request flag which needs to be set to account a transaction -- RADIUS
  176. specific.
  177. Default value is 1.
  178. Example 12. radius_flag example
  179. modparam("acc", "radius_flag", 2)
  180. 1.3.12. radius_missed_flag (integer)
  181. Request flag which needs to be set to account missed calls -- RADIUS
  182. specific.
  183. Default value is 2.
  184. Example 13. radius_missed_flag example
  185. modparam("acc", "radius_missed_flag", 3)
  186. 1.3.13. db_url (string)
  187. SQL address -- database specific.
  188. Default value is "mysql://ser:heslo@localhost/ser"
  189. Example 14. db_url example
  190. modparam("acc", "db_url", "mysql://user:password@localhost/ser")
  191. 1.3.14. db_flag (integer)
  192. Request flag which needs to be set to account a transaction -- database
  193. specific.
  194. Default value is 1.
  195. Example 15. db_flag example
  196. modparam("acc", "db_flag", 2)
  197. 1.3.15. db_missed_flag (integer)
  198. Request flag which needs to be set to account missed calls -- database
  199. specific.
  200. Default value is 2.
  201. Example 16. db_missed_flag example
  202. modparam("acc", "db_missed_flag", 3)
  203. 1.3.16. diameter_flag (integer)
  204. Request flag which needs to be set to account a transaction -- DIAMETER
  205. specific.
  206. Default value is 1.
  207. Example 17. diameter_flag example
  208. modparam("acc", "diameter_flag", 2)
  209. 1.3.17. diameter_missed_flag (integer)
  210. Request flag which needs to be set to account missed calls -- DIAMETER
  211. specific.
  212. Default value is 2.
  213. Example 18. diameter_missed_flag example
  214. modparam("acc", "diameter_missed_flag", 3)
  215. 1.3.18. diameter_client_host (string)
  216. Hostname of the machine where the DIAMETER Client is running --
  217. DIAMETER specific.
  218. Default value is "localhost".
  219. Example 19. diameter_client_host example
  220. modparam("acc", "diameter_client_host", "iptel.org")
  221. 1.3.19. diameter_client_port (int)
  222. Port number where the Diameter Client is listening -- DIAMETER
  223. specific.
  224. Default value is 3000.
  225. Example 20. diameter_client_host example
  226. modparam("acc", "diameter_client_port", 3000)
  227. 1.4. Functions
  228. 1.4.1. acc_log_request(comment)
  229. acc_request reports on a request, for example, it can be used to report
  230. on missed calls to off-line users who are replied 404. To avoid
  231. multiple reports on UDP request retransmission, you would need to embed
  232. the action in stateful processing.
  233. Meaning of the parameters is as follows:
  234. * comment - Comment to be appended.
  235. Example 21. acc_log_request usage
  236. ...
  237. acc_log_request("Some comment");
  238. ...
  239. 1.4.2. acc_db_request(comment, table)
  240. Like acc_log_request, acc_db_request reports on a request. The report
  241. is sent to database at "db_url", in the table referred to in the second
  242. action parameter
  243. Meaning of the parameters is as follows:
  244. * comment - Comment to be appended.
  245. * table - Database table to be used.
  246. Example 22. acc_db_request usage
  247. ...
  248. acc_log_request("Some comment", "Some table");
  249. ...
  250. 1.4.3. acc_rad_request(comment)
  251. Like acc_log_request, acc_rad_request reports on a request. It reports
  252. to radius server as configured in "radius_config".
  253. Meaning of the parameters is as follows:
  254. * comment - Comment to be appended.
  255. Example 23. acc_rad_request usage
  256. ...
  257. acc_rad_request("Some comment");
  258. ...
  259. 1.4.4. acc_diam_request(comment)
  260. Like acc_log_request, acc_diam_request reports on a request. It reports
  261. to Diameter server.
  262. Meaning of the parameters is as follows:
  263. * comment - Comment to be appended.
  264. Example 24. acc_diam_request usage
  265. ...
  266. acc_diam_request("Some comment");
  267. ...