smsgw.cfg 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #
  2. # $Id$
  3. #
  4. # bat.iptel.org (sms gateway) real world configuration
  5. #
  6. # ----------- global configuration parameters ------------------------
  7. debug=3 # debug level (cmd line: -dddddddddd)
  8. fork=yes
  9. #fork=no
  10. log_stderror=no # (cmd line: -E)
  11. #log_stderror=yes # (cmd line: -E)
  12. check_via=yes # (cmd. line: -v)
  13. dns=on # (cmd. line: -r)
  14. rev_dns=yes # (cmd. line: -R)
  15. port=5070
  16. children=2
  17. # advertise IP address in Via (as opposed to advertising DNS name
  18. # which is annoying for downstream servers and some phones can
  19. # not handle DNS at all)
  20. listen=195.37.77.100
  21. # ------------------ module loading ----------------------------------
  22. loadmodule "../sip_router/modules/sl/sl.so"
  23. loadmodule "../sip_router/modules/print/print.so"
  24. loadmodule "../sip_router/modules/tm/tm.so"
  25. loadmodule "../sip_router/modules/maxfwd/maxfwd.so"
  26. loadmodule "../sip_router/modules/sms/sms.so"
  27. # ----------------- setting module-specific parameters ---------------
  28. # -- sms params --
  29. modparam("sms","modems","Falcom [d=/dev/ttyS0;b=9600;p=9254;m=new;l=10;r=2]")
  30. modparam("sms","networks","D1[c=491710765000;m=10]")
  31. modparam("sms","links","Falcom[D1]")
  32. modparam("sms","domain","iptel.org")
  33. modparam("sms","max_sms_parts",3)
  34. modparam("sms","use_contact",1)
  35. # -- tm params --
  36. modparam("tm", "fr_timer", 10 )
  37. modparam("tm", "fr_inv_timer", 10 )
  38. modparam("tm", "wt_timer", 10 )
  39. # ------------------------- request routing logic -------------------
  40. # main routing logic
  41. route{
  42. if (len_gt( max_len )) {
  43. sl_send_reply("513", "Riesengross -- Message too large");
  44. break;
  45. };
  46. # filter too old messages
  47. log("LOG: Checking maxfwd\n");
  48. if (!mf_process_maxfwd_header("10")) {
  49. log("LOG: Too many hops\n");
  50. sl_send_reply("483","Too Many Hops");
  51. break;
  52. };
  53. # accept only req coming from iptel.org
  54. if (!src_ip==195.37.77.101 |
  55. !( uri=~"iptel.org" | uri=~"195\.37\.77\.100" ))
  56. {
  57. log("SER:Forbidden request: wrong src_ip or req_uri\n");
  58. sl_send_reply("403","Forbidden");
  59. break;
  60. };
  61. #accept only MESSAGE requests
  62. if (!method=="MESSAGE")
  63. {
  64. sl_send_reply("501","Not Implemented");
  65. break;
  66. };
  67. # SMS expects the numbers as follows <int> <area> <nr>
  68. # align numbering to it
  69. if (uri=~"sip:001" ) {
  70. strip(2);
  71. prefix("49");
  72. } else if (uri=~"sip:\+491") {
  73. strip(1);
  74. } else if (uri=~"sip:000491") {
  75. strip(3);
  76. } else {
  77. sl_send_reply("403", "SMS only to German 01* networks");
  78. break;
  79. };
  80. if (! t_newtran())
  81. {
  82. # retransmit whatever we have
  83. # it's useless to do any retransmision, because we haven't
  84. # sent any statefull reply. (bogdan)
  85. #t_retransmit_reply();
  86. break;
  87. } else {
  88. # do what you want to do
  89. if (sms_send_msg_to_net("D1"))
  90. {
  91. # for sending replies, we woun't use the statefull
  92. # function because it is not able to add the Contact
  93. # header (in fact to add any rpl_lump :-( )
  94. # things went well, send ok upstream
  95. if (!sl_send_reply("202", "yes sir, SMS sent over"))
  96. {
  97. # if replying failed, retry statelessly
  98. sl_reply_error();
  99. };
  100. } else {
  101. if (!sl_send_reply("502", "Bad gateway - SMS error"))
  102. {
  103. # if replying failed, retry statelessly
  104. sl_reply_error();
  105. };
  106. };
  107. # transaction conclude it -- junk it now (it will
  108. # stay there until WAIT timer hits)
  109. t_release();
  110. };
  111. t_unref();
  112. }