[OpenSIPS-Devel] How to reject a SIP message from OpenSIPS core
Răzvan Crainea
razvan at opensips.org
Tue Jul 23 14:46:13 CEST 2013
Hi, Muhammad!
Using the set_err_code() function only sets some internal OpenSIPS
variables that can be later on used in an error_route() [1]. So
basically you simply mark what type of error it was, but you are not
sending any reply back.
I think the code you have there is good (except probably you should also
set an error class, see: set_err_info() function), but nobody handles it
from the error_route(). Following the example in the documentation
should do the trick.
[1] http://www.opensips.org/Documentation/Script-Routes#toc5
Best regards,
Răzvan Crainea
OpenSIPS Core Developer
http://www.opensips-solutions.com
On 07/23/2013 05:48 AM, Muhammad Shahzad Shafi wrote:
> I am experimenting with some stuff, where i action.c in method
> run_top_route (immediately after variable declaration) i have added an
> IF condition, if that matches i want to reject SIP request e.g. with 403
> Forbidden.
>
> I tried this code,
>
> if(my_condition_is_true) {
> LM_CRIT("CRIT - Not going to process this message...");
> set_err_reply(403, "Forbidden");
> return EXIT_T;
> }
>
> But it does not work (though i can see log message after condition is
> matched), the message is silently dropped without sending 403 response
> first. If i remove the return statement and let it flow through rest of
> method, then message is processed according to opensips.cfg but still
> 403 isn't received at client.
>
> What am i doing wrong here? Is there any better approach (different file
> and/or different method) where i put my IF condition to drop matched
> packet. I want to do it in native code, NOT in opensips.cfg.
>
> Thank you.
>
>
More information about the Devel
mailing list