if I do lookup()
What case does lookup return if entry exists but user not registered?
lookup("location"); switch ($retcode) { case -1: case -3: sl_send_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Not Found"); exit; };
should I just wrap this like this:
if(registered("location")){
lookup("location"); switch ($retcode) { case -1: case -3: sl_send_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Not Found"); exit;
} };
The purpose I ask this rather simple question is because I want to redirect to voicemail if user is not registered. In the default script we have this case;
failure_route[FAIL_ONE] { # uncomment the following lines if you want to redirect the failed # calls to a different new destination ##if (t_check_status("486|408")) { ## sethostport("192.168.2.100:5060"); ## append_branch(); ## # do not set the missed call flag again ## t_relay(); ##} }
But it seems this case is never met;
Because this code
lookup("location"); switch ($retcode) { case -1: case -3: sl_send_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Not Found"); exit; };
Seems to send a 404 response to the UA rather than go to failure route?
Maybe I am wrong...
Any advice would be appreciated.
Am 22.12.2010 04:13, schrieb David J.:
if I do lookup()
What case does lookup return if entry exists but user not registered?
Ask the manual: http://www.kamailio.org/docs/modules/3.1.x/modules_k/registrar.html#id252751...
Because this code
lookup("location"); switch ($retcode) { case -1: case -3: sl_send_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Not Found"); exit; };
Seems to send a 404 response to the UA rather than go to failure route?
True. In your case you could simply use
if (!lookup("location")) { # for any reason the lookup failed, send to voicemail # e.g. forward to voicemail server at 1.2.3.4 but leave # the request URI unchanged: $du = "sip:1.2.3.4"; t_relay(); exit; } # continue with normal call routing ...
regards klaus