Advertisement
Guest User

kamailio config snippet

a guest
Sep 19th, 2024
83
0
98 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.65 KB | Source Code | 0 0
  1. loadmodule "ndb_redis.so"
  2. loadmodule "topos.so"
  3. loadmodule "topos_redis.so"
  4.  
  5. modparam("ndb_redis", "server", "name=localsrv;addr=127.0.0.1;port=6379;db=1")
  6. modparam("topos", "storage", "redis")
  7. modparam("topos_redis", "serverid", "localsrv")
  8.  
  9. /* Main SIP request routing logic
  10.  * - processing of any incoming SIP request starts with this route
  11.  * - note: this is the same as route { ... } */
  12. request_route {
  13.  
  14. /* 8< cut parts basically same as default 8< */
  15.        
  16.         # handle requests within SIP dialogs
  17.         route(WITHINDLG);
  18.        
  19.         ### only initial requests (no To tag)
  20.        
  21.         dlg_manage();
  22.          
  23.         # record routing for dialog forming requests (in case they are routed)
  24.         # - remove preloaded route headers
  25.         remove_hf("Route");
  26.         record_route();
  27.        
  28.         # account only INVITEs
  29.         if (is_method("INVITE")) {
  30.                 #setflag(FLT_ACC); # do accounting
  31.                 add_path();
  32.         }
  33.  
  34. /* 8< cut parts basically same as default 8< */
  35.        
  36.         # reply fast 100 on register
  37.         if (is_method("REGISTER"))
  38.                 sl_send_reply("100","Trying");
  39.        
  40.         route(RELAY);
  41.        
  42.         exit;
  43. }
  44.  
  45.  
  46. # Handle requests within SIP dialogs
  47. route[WITHINDLG] {
  48.         if (!has_totag()) return;
  49.          
  50.         # sequential request withing a dialog should
  51.         # take the path determined by record-routing
  52.         if (loose_route()) {
  53.                
  54.                 route(DLGURI);
  55.                 if ( is_method("ACK") ) {
  56.                         # ACK is forwarded statelessly
  57.                         route(NATMANAGE);
  58.                 } else if ( is_method("NOTIFY") ) {
  59.                         # Add Record-Route for in-dialog NOTIFY as per RFC 6665.
  60.                         record_route();
  61.                 }
  62.                 route(RELAY);
  63.                 exit;
  64.         }
  65.        
  66.         if (is_method("SUBSCRIBE") && uri == myself) {
  67.                 # in-dialog subscribe requests
  68.                 sl_send_reply("404", "No voicemail service");
  69.                 exit;
  70.         }
  71.         if ( is_method("ACK") ) {
  72.                 if ( t_check_trans() ) {
  73.                         # no loose-route, but stateful ACK;
  74.                         # must be an ACK after a 487
  75.                         # or e.g. 404 from upstream server
  76.                         route(RELAY);
  77.                         exit;
  78.                 } else {
  79.                         # ACK without matching transaction ... ignore and discard
  80.                         exit;
  81.                 }
  82.         }
  83.         sl_send_reply("404","Not here");
  84.         exit;
  85. }
  86.  
Tags: VoIP Kamailio
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement