Advertisement
covalschi

Request route

Feb 24th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. request_route {
  2. if ((($Rp == MY_WS_PORT || $Rp == MY_WSS_PORT)
  3. && !(proto == WS || proto == WSS))) {
  4. xlog("L_WARN", "SIP request received on $Rp\n");
  5. sl_send_reply("403", "Forbidden");
  6. exit;
  7. }
  8.  
  9. # per request initial checks
  10. route(REQINIT);
  11.  
  12. # NAT detection
  13. route(NATDETECT);
  14.  
  15. # CANCEL processing
  16. if (is_method("CANCEL")) {
  17. if (t_check_trans()) {
  18. route(RELAY);
  19. }
  20. exit;
  21. }
  22.  
  23. # handle requests within SIP dialogs
  24. route(WITHINDLG);
  25.  
  26. ### only initial requests (no To tag)
  27.  
  28. t_check_trans();
  29.  
  30. if (!is_method("REGISTER|INVITE|ACK|BYE|CANCEL|PRACK|MESSAGE|INFO|UPDATE")) {
  31. sl_send_reply("405", "Method not allowed");
  32. exit;
  33. }
  34.  
  35. # authentication
  36. route(AUTH);
  37.  
  38. # record routing for dialog forming requests (in case they are routed)
  39. # - remove preloaded route headers
  40. remove_hf("Route");
  41. if (is_method("INVITE|SUBSCRIBE")){
  42. record_route();
  43. }
  44. # handle registrations
  45. route(REGISTRAR);
  46.  
  47. if ($rU==$null) {
  48. # request with no Username in RURI
  49. sl_send_reply("484","Address Incomplete");
  50. exit;
  51. }
  52.  
  53. if (!is_method("INVITE")) {
  54. route(RELAY);
  55. exit;
  56. }
  57.  
  58. route(PSTN);
  59.  
  60. route(LOCATION);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement