config_migration.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. =============================================================
  2. = Config migration guide from ser or kamailio to sip-router =
  3. =============================================================
  4. ser 2.1 config migration
  5. ========================
  6. 1. Avps, selects and strings in if or other expressions
  7. The most important change is the different way in which avp and select are
  8. evaluated in boolean expressions (if ()).
  9. In ser "if ($v){}" or "if (@select){}" were true if the avp or select were
  10. "defined" and if their value was non-empty (!= "").
  11. In sip-router this changed: the ifs will be true if the avp or select are
  12. non-empty and they evaluate to a non-zero number. The catch is that a
  13. non-numeric string evaluates to 0 (e.g. "abc" evaluates to 0, "123" evaluates
  14. to 123, "" to 0, "0" to 0).
  15. Something like "if($v)" should be used only if $v is supposed to have a numeric
  16. value. "if (@select)" should not be used in general (it's probably not what you
  17. want).
  18. The equivalent sip-router checks are:
  19. instead of if ($v) use if ($v != "")
  20. instead of if (!$v) use if ($v == "") or if (strempty($v)).
  21. instead of if (@select) use if (@select != "")
  22. instead of if (!@select) use if (@select == "") or if (strempty(@select)).
  23. If the test is for value existence, then if ($v) can be replaced with
  24. if (defined $v).
  25. E.g.:
  26. replace
  27. if (! $f.did)
  28. with
  29. if (strempty($f.did))
  30. replace
  31. if (method=="INVITE" && [email protected])
  32. with
  33. if (method=="INVITE" && strempty(@to.tag))
  34. replace
  35. if ($f.did && ! $t.did)
  36. with
  37. if ($f.did != "" && $t.did == "")
  38. replace
  39. if (@to.tag)
  40. with
  41. if (@to.tag != "")
  42. 2. Module path
  43. While in ser there was only a single directory holding the modules, now there
  44. are 3: modules (for common modules), modules_s (for ser modules) and modules_k
  45. (for kamailio modules).
  46. The easiest way to migrate a ser config is to add:
  47. loadpath "/usr/lib/ser/modules:/usr/lib/ser/modules_s"
  48. at the beginning (before any loadmodule command).
  49. This will set the module search path to first look into the common modules and
  50. if not found in the ser modules.
  51. Make sure that all the loadmodule commands do not include the path to the
  52. module or the .so extension (or else they won't make use of the loadpath).
  53. E.g.:
  54. replace
  55. loadmodule "/usr/lib/ser/modules/tm.so"
  56. with
  57. loadmodule "tm"
  58. 3. Module names
  59. Some of the modules changed their name (usually after being merged with the
  60. kamailio ones).
  61. The most common changes are mysql -> db_mysql and postgres -> db_postgres.
  62. E.g.:
  63. replace
  64. loadmodule "mysql"
  65. with
  66. loadmodule "db_mysql"
  67. 4. msg:len and max_len
  68. max_len was removed. All the comparisons of msg:len with max_len must be
  69. changed to use a number (e.g. 4096 or 16384) instead of max_len.
  70. Comparing with max_len didn't make sense anyway since max_len was the size of
  71. the internal receive buffer on UDP. You could never exceed it, unless you were
  72. using TCP configured in a non-standard way.
  73. E.g.:
  74. replace
  75. if (msg:len >= max_len)
  76. with
  77. if (msg:len >= 4096)
  78. kamailio config migration
  79. =========================
  80. [TODO: probably most of the things from the ser section apply too]