alg.cfg 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # $Id$
  2. #
  3. # Simple application level gateway config script.
  4. #
  5. # Assumes that SER/rtpproxy run on a machine, which connected to
  6. # two non-routable letworks: 192.168.0.0/24 and 192.168.1.1/24.
  7. #
  8. # Correspondingly, this machine has two IP addresses: 192.168.0.1
  9. # and 192.168.1.1.
  10. #
  11. # 192.168.0.0/24 - "internal" network
  12. # 192.168.1.0/24 - "external" network
  13. #
  14. # rtpproxy started with `-l 192.168.0.1/192.168.1.1' option.
  15. #
  16. # ------------------ module loading ----------------------------------
  17. loadmodule "/usr/local/lib/ser/modules/sl.so"
  18. loadmodule "/usr/local/lib/ser/modules/tm.so"
  19. loadmodule "/usr/local/lib/ser/modules/rr.so"
  20. loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
  21. loadmodule "/usr/local/lib/ser/modules/usrloc.so"
  22. loadmodule "/usr/local/lib/ser/modules/registrar.so"
  23. loadmodule "/usr/local/lib/ser/modules/nathelper.so"
  24. loadmodule "/usr/local/lib/ser/modules/rtpproxy.so"
  25. # ----------------- setting module-specific parameters ---------------
  26. # -- nathelper params --
  27. modparam("nathelper", "natping_interval", 15)
  28. # ------------------ main fun below ----------------------------------
  29. route {
  30. # initial sanity checks -- messages with
  31. # max_forwars == 0, or excessively long requests,
  32. # or those that don't addressed to us
  33. if (!mf_process_maxfwd_header("10")) {
  34. sl_send_reply("483", "Too Many Hops");
  35. break;
  36. };
  37. if (msg:len > max_len) {
  38. sl_send_reply("513", "Message too big");
  39. break;
  40. };
  41. if (!(uri == myself) && method == "INVITE") {
  42. sl_send_reply("403", "Call cannot be served here");
  43. break;
  44. };
  45. if (method == "REGISTER") {
  46. if (dst_ip == 192.168.0.1) {
  47. save("location-internal");
  48. } else if (dst_ip == 192.168.1.1) {
  49. save("location-external");
  50. } else {
  51. sl_send_reply("403", "Call cannot be served here");
  52. };
  53. break;
  54. };
  55. if (method == "INVITE") {
  56. if (lookup("location-internal")) {
  57. if (dst_ip == 192.168.0.1)
  58. if (rtpproxy_offer("FAII"))
  59. t_on_reply("1");
  60. if (dst_ip == 192.168.1.1)
  61. if (rtpproxy_offer("FAEI"))
  62. t_on_reply("1");
  63. } else if (lookup("location-external")) {
  64. if (dst_ip == 192.168.0.1)
  65. if (rtpproxy_offer("FAIE"))
  66. t_on_reply("1");
  67. if (dst_ip == 192.168.1.1)
  68. if (rtpproxy_offer("FAEE"))
  69. t_on_reply("1");
  70. } else {
  71. sl_send_reply("403", "Call cannot be served here");
  72. break;
  73. };
  74. }
  75. if (method == "BYE" || method == "CANCEL")
  76. unforce_rtp_proxy();
  77. # Do strict routing if pre-loaded route headers present
  78. if (loose_route()) {
  79. t_relay();
  80. break;
  81. };
  82. if (method == "INVITE")
  83. record_route();
  84. if (!t_relay())
  85. sl_reply_error();
  86. }
  87. onreply_route[1] {
  88. if (!(status=~"183" || status=~"200"))
  89. break;
  90. rtpproxy_answer("FA");
  91. }