tmtest.cfg 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. #
  2. # $Id$
  3. #
  4. # iptel.org real world configuration
  5. #
  6. # ----------- global configuration parameters ------------------------
  7. #debug=8 # debug level (cmd line: -dddddddddd)
  8. debug=3
  9. #fork=yes
  10. fork=no
  11. children=2
  12. #log_stderror=no # (cmd line: -E)
  13. log_stderror=yes # (cmd line: -E)
  14. check_via=yes # (cmd. line: -v)
  15. dns=on # (cmd. line: -r)
  16. rev_dns=yes # (cmd. line: -R)
  17. port=5060
  18. #port=8060
  19. # advertise IP address in Via (as opposed to advertising DNS name
  20. # which is annoying for downstream servers and some phones can
  21. # not handle DNS at all)
  22. listen=195.37.77.100
  23. # ------------------ module loading ----------------------------------
  24. loadmodule "../sip_router/modules/sl/sl.so"
  25. loadmodule "../sip_router/modules/print/print.so"
  26. #loadmodule "../sip_router/modules/tm/tm.so"
  27. loadmodule "../sip_router/modules/acc/acc.so"
  28. loadmodule "../sip_router/modules/rr/rr.so"
  29. loadmodule "../sip_router/modules/maxfwd/maxfwd.so"
  30. #loadmodule "../sip_router/modules/mysql/mysql.so"
  31. loadmodule "../sip_router/modules/usrloc/usrloc.so"
  32. #loadmodule "../sip_router/modules/auth/auth.so"
  33. loadmodule "../sip_router/modules/cpl/cpl.so"
  34. # ----------------- setting module-specific parameters ---------------
  35. # -- usrloc params --
  36. modparam("usrloc", "use_database", 0)
  37. modparam("usrloc", "flush_interval", 3600)
  38. # -- acc params --
  39. # report ACKs too for sake of completeness -- as we account PSTN
  40. # destinations which are RR, ACKs should show up
  41. modparam("acc", "report_ack", 1)
  42. # don't bother me with early media reports (I don't like 183
  43. # too much anyway...ever thought of timer C hitting after
  44. # listening to music-on-hold for five minutes?)
  45. modparam("acc", "early_media", 0)
  46. modparam("acc", "log_level", 1)
  47. # that is the flag for which we will account -- don't forget to
  48. # set the same one :-)
  49. modparam("acc", "acc_flag", 3 )
  50. # we are interested only in succesful transactions
  51. modparam("acc", "failed_transactions", 0 )
  52. # -- tm params --
  53. modparam("tm", "fr_timer", 10 )
  54. modparam("tm", "fr_inv_timer", 10 )
  55. modparam("tm", "wt_timer", 1000 )
  56. modparam("tm", "noisy_ctimer", 1 )
  57. # ------------------------- request routing logic -------------------
  58. # main routing logic
  59. route{
  60. #t_uac();
  61. # filter local stateless ACK generated by authentication of mf replies
  62. sl_filter_ACK();
  63. # filter too old messages
  64. log("LOG: Checking maxfwd\n");
  65. if (!mf_process_maxfwd_header("10")) {
  66. log("LOG: Too many hops\n");
  67. sl_send_reply("483","Too Many Hops");
  68. break;
  69. };
  70. # len_gt *after* max_fwd, otherwise an "INVITE sip:[email protected]"
  71. # will cause "message too big" for a short message
  72. if (len_gt( max_len )) {
  73. sl_send_reply("513", "Riesengross -- Message too large");
  74. break;
  75. };
  76. # Do strict routing if route headers present
  77. rewriteFromRoute();
  78. # look at whether we need record-routing;
  79. # - we need it for calls from gateways (otherwise, subsequent
  80. # requests from the other # party will attempt to contact gateway
  81. # directly through blocked ports)
  82. # - we need it for Windows Messanger's IM sessions to cross
  83. # firewalls -- we force all MESSAGEs to go via our server
  84. # to avoid blocking port numbers (some firewalls can do
  85. # standard SIP but are puzzled by Microsoft's proprietary
  86. # messaging session model)
  87. # - some other places may decide to set the record-routing
  88. # flag (2 chosen) too; particularly, INVITEs to our gw
  89. if ( (src_ip==195.37.77.110 & method=="INVITE") || method=="MESSAGE" || method=="INFO" ) {
  90. setflag(2);
  91. };
  92. # if this request is not for our domain, fall over to
  93. # outbound request processing; include gateway's address
  94. # in matching too -- we RR requests to it, so that
  95. # its address may show up in subsequent requests
  96. # after rewriteFromRoute
  97. # sign of our domain: there is @ (username), :
  98. # (nothing) or . (host) in front of our domain name
  99. if (!(uri=~"bat\.iptel\.org([;:].*)*"
  100. | uri=~"[@:\.]195\.37\.77\.101([;:].*)*" |
  101. uri=~"@195\.37\.77\.110([;:].*)*" )) {
  102. route(2);
  103. # break from route (2) return -- stop then !
  104. break;
  105. };
  106. # here we continue with requests for our domain...
  107. # registers always MUST be authenticated to
  108. # avoid stealing incoming calls
  109. if (method=="REGISTER") {
  110. log("LOG Request is REGISTER\n");
  111. # prohibit attempts to grab someone else's To address
  112. # using valid credentials; the only exception is the user
  113. # 'replciator' permitted to generate 3-rd party registrations
  114. # update Contact database
  115. log("LOG: REGISTER is authorized, saving location\n");
  116. save_contact("location");
  117. break;
  118. };
  119. # now check if it's about PSTN destinations through our gateway;
  120. # note that 8.... is exempted for numerical destinations
  121. if (uri=~"sip:\+?[0-79][0-9]*@.*") {
  122. route(3);
  123. # break from route (3) return -- stop then !
  124. break;
  125. };
  126. # native SIP destinations are handled using our USRLOC DB
  127. if (!lookup_contact("location")) {
  128. if (method=="ACK") {
  129. log("Ooops -- an ACK made it here -- probably UAC screwed up to-tags\n");
  130. break;
  131. };
  132. log("LOG: Unable to lookup contact, sending 404\n");
  133. sl_send_reply("404", "Not Found");
  134. break;
  135. };
  136. # requests from gateway should be RR-ed too
  137. if (isflagset(2)) {
  138. addRecordRoute();
  139. };
  140. # we now know we may, we know where, let it go out now!
  141. if (!t_relay()) {
  142. sl_reply_error();
  143. break;
  144. };
  145. }
  146. #---------------------------------------------------------------------
  147. # routing logic for outbound requests targeted out of our domain
  148. # (beware, messages to our users can end up here too: for example,
  149. # an INVITE may be UsrLoc-ed, then the other party uses outbound
  150. # proxy with r-uri=the usr_loced addredd (typically IP))
  151. route[2] {
  152. # requests from gateway should be RR-ed too
  153. if (isflagset(2)) {
  154. addRecordRoute();
  155. };
  156. if (!t_relay()) {
  157. sl_reply_error();
  158. break;
  159. };
  160. }
  161. #---------------------------------------------------------------------
  162. # logic for calls through our PSTN gateway
  163. route[3] {
  164. # if it is a MESSAGE pass it "as is" over to our SMS gateway
  165. # (which unfortunately lives at a different host due to
  166. # lack of serial interfaces)
  167. if (method=="MESSAGE") {
  168. # note that we don't do any admission control yet:
  169. # anyone can SMS anywhere;
  170. setflag(1);
  171. rewritehostport("195.37.77.100:5070");
  172. if (!t_relay()) {
  173. sl_reply_error();
  174. };
  175. break;
  176. };
  177. # continue with requests to PSTN gateway ...
  178. # the international + prefix
  179. if (uri=~"sip:\+" ) {
  180. strip(1);
  181. prefix("000");
  182. };
  183. # free call destinations ... no authentication needed
  184. if (uri=~"sip:001795061546@.*" | uri=~"sip:0016097265544.*"
  185. | uri=~"sip:[79][0-9][0-9][0-9]@.*"
  186. | uri=~"sip:98[0-9][0-9][0-9][0-9]") {
  187. log("LOG: Free PSTN\n");
  188. # let's log free calls for now too ...
  189. setflag(1);
  190. } else {
  191. # we passed all authorization checks for PSTN -- move on!
  192. # tag this transaction for accounting
  193. setflag(1);
  194. }; # authorized PSTN
  195. # requests to gateway must be record-routed because the GW accepts
  196. # only reqeusts coming from our proxy
  197. if (isflagset(2) || method=="INVITE")
  198. addRecordRoute();
  199. # if you have passed through all the checks, let your call go to GW!
  200. rewritehostport("fox.iptel.org:5060");
  201. if (!t_relay()) {
  202. sl_reply_error();
  203. break;
  204. };
  205. }