[SR-Users] Programmatically modify SIP Requests/Responses in Kamailio

Alex Balashov abalashov at evaristesys.com
Tue Feb 12 18:57:24 CET 2019


Hi Filippos,

Kamailio can indeed modify many aspects of a SIP message, though the
devil is in the details. 

https://kamailio.org/docs/modules/5.2.x/modules/textops.html
https://kamailio.org/docs/modules/5.2.x/modules/textopsx.html

Many message attributes are exposed through "pseudovariables":

https://www.kamailio.org/wiki/cookbooks/5.2.x/pseudovariables

A handful of which (such as $ru) are mutable. 

Headers can be accessed on a read-only basis through the $hdr()
pseudovariable:

https://www.kamailio.org/wiki/cookbooks/5.2.x/pseudovariables#hdr_name_-_headers

There are, of course, formal limits to what headers and attributes a
proxy is allowed to modify, by virtue of being in series to the same
logical SIP call leg in and out. Even then, Kamailio has some elaborate
contrivances for working around this in clever ways:

https://kamailio.org/docs/modules/5.2.x/modules/uac.html

"Business logic to figure out what action to take with a SIP request"
probably describes most useful applications of Kamailio. It wouldn't
have much viability as infrastructure if it did not have that
capability.

-- Alex

On Tue, Feb 12, 2019 at 05:00:20PM +0100, Filippos Vasilakis wrote:

> Hi,
> 
> First of all I would like to congratulate and thank everyone who has worked
> in Kamailio. It looks like an awesome tool.
> 
> I am starting a side project and I am not very familiar with Kamailio
> although I know SIP and VoIP in general, so I am more looking for answers
> that tell me if it's possible or not what I am asking along with some hints
> on how/where to look.
> 
> Is there a way to filter/forward/modify(through the headers) incoming SIP
> requests and Kamailio SIP responses programmatically in Kamailio ? I have
> seen that you can run embedded code like Ruby, but I wonder if this is for
> simple things or more complex stuff which probably is in my case since
> there will be plenty of business logic to figure out what action to take
> with a SIP request. I have also found the EVAPI that is supposed to be
> handle events through TCP but not much more info available.
> 
> So to sum up, is there a way to filter/forward/modify incoming SIP requests
> and create responses programmatically in Kamailio ? If yes, what's the
> proper way of doing that ? If no, any idea where I should look for that?
> 
> Thanks,
> Filippos

> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/



More information about the sr-users mailing list