[OpenSIPS-Devel] How to reject a SIP message from OpenSIPS core

Muhammad Shahzad Shafi shahzad at voip-demos.com
Tue Jul 23 19:38:21 CEST 2013


Thanks Räzvan, you saved my day.

Thank you.


On 2013-07-23 14:46, Răzvan Crainea wrote:
> 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.
>>
>>
>
> _______________________________________________
> Devel mailing list
> Devel at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/devel

-- 
Mit freundlichen Grüßen
Muhammad Shahzad
-----------------------------------
CISCO Rich Media Communication Specialist (CRMCS)
CISCO Certified Network Associate (CCNA)
Cell: +49 176 99 83 10 85
MSN: shari_786pk at hotmail.com
Email: shaheryarkh at googlemail.com



More information about the Devel mailing list