welcome.cfg 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #
  2. # $Id$
  3. #
  4. # welcome message for new subscribers; based on exec
  5. #
  6. # ----------- global configuration parameters ------------------------
  7. debug=3 # debug level (cmd line: -dddddddddd)
  8. # must be yes since REGISTER processing causes an INVITE to be sent,
  9. # which needs to be processed by another process
  10. fork=yes
  11. children=4
  12. # debugging
  13. log_stderror=yes # (cmd line: -E)
  14. mhomed=yes
  15. fifo="/tmp/ser_fifo"
  16. # ------------------ module loading ----------------------------------
  17. # Uncomment this if you want to use SQL database
  18. loadmodule "modules/mysql/mysql.so"
  19. loadmodule "modules/sl/sl.so"
  20. loadmodule "modules/tm/tm.so"
  21. loadmodule "modules/rr/rr.so"
  22. loadmodule "modules/maxfwd/maxfwd.so"
  23. loadmodule "modules/usrloc/usrloc.so"
  24. loadmodule "modules/registrar/registrar.so"
  25. loadmodule "modules/exec/exec.so"
  26. # ----------------- setting module-specific parameters ---------------
  27. # -- usrloc params --
  28. modparam("usrloc", "db_mode", 2)
  29. modparam("usrloc", "db_url", "mysql://ser:[email protected]/ser" )
  30. # ------------------------- request routing logic -------------------
  31. # main routing logic
  32. route{
  33. # initial sanity checks -- messages with
  34. # max_forwards==0, or excessively long requests
  35. if (!mf_process_maxfwd_header("10")) {
  36. sl_send_reply("483","Too Many Hops");
  37. break;
  38. };
  39. if (len_gt( max_len )) {
  40. sl_send_reply("513", "Message too big");
  41. break;
  42. };
  43. # we record-route all messages -- to make sure that
  44. # subsequent messages will go through our proxy; that's
  45. # particularly good if upstream and downstream entities
  46. # use different transport protocol
  47. if (method=="INVITE") record_route(); # 1=loose routing
  48. # loose-route processing
  49. if (loose_route()) {
  50. t_relay();
  51. break;
  52. };
  53. log(1, "RR processing completed\n");
  54. # if the request is for other domain use UsrLoc
  55. # (in case, it does not work, use the following command
  56. # with proper names and addresses in it)
  57. if (uri==myself) {
  58. if (method=="REGISTER") {
  59. # save location before initiating welcome
  60. save("location");
  61. # welcome message
  62. route(3);
  63. break;
  64. };
  65. # native SIP destinations are handled using our USRLOC DB
  66. if (!lookup("location")) {
  67. sl_send_reply("404", "Not Found");
  68. break;
  69. };
  70. };
  71. t_relay();
  72. }
  73. # welcome message -- if a REGISTER succeeded, look if it is the first-time;
  74. # if so, initiate click-to-dial transaction to set up call to an announcement
  75. # server; edit the config values first to make it work
  76. route[3] {
  77. if (!exec_msg('
  78. # config:
  79. # --announcement server URI
  80. ANS="sip:[email protected]"
  81. # --SIP domain
  82. DOMAIN="192.168.2.16"
  83. # ctd
  84. CTD=${HOME}/sip_router/examples/ctd.sh
  85. # ------------------------------------
  86. # check if first time ...
  87. SIP_UID=`echo $SIP_HF_TO | sed -e "s/^.*sip:\([a-zA-Z0-9_\.]*\)@.*$/\1/g"`
  88. QUERY="select flag from subscriber
  89. where username=\"$SIP_UID\";
  90. update subscriber set flag=\"x\"
  91. where username=\"$SIP_UID\" ";
  92. mysql -Bsuser -pheslo -e "$QUERY" ser| grep "^x$" > /dev/null
  93. # ... if so, c-t-d to announcement server
  94. if [ "$?" -ne 0 ] ; then
  95. # flag was not set to x yet -- first-time registration;
  96. # initiate a call from telephone of the user to an announcement server
  97. $CTD "sip:$SIP_UID@$DOMAIN" "$ANS" > /dev/null 2>&1
  98. fi
  99. ')) {
  100. log(1, "welcome exec failed\n");
  101. }
  102. }