[SR-Users] Record-Route IP Value

Alex Balashov abalashov at evaristesys.com
Mon Oct 30 05:33:04 CET 2017


Hi,

On Sat, Oct 28, 2017 at 05:34:04PM +0300, Soltanici Ilie wrote:

> Having the following Header: 
> Record-Route: <sip:192.168.1.1;lr;did=637.07c7c2d7>
> 
> How can i extract only IP value from this header?

Generally, when presented with a URI, you can extract the host/domain
component using the URI transformations, e.g.

   $(hdr(Record-Route){nameaddr.uri}{uri.host})

If you are dealing with a single Record-Route header that has a singular
URI value, this should work fine.

More generally, a concern here would be that Record-Routes can occur in
a variety of configurations. For one, they can be stacked if the message
has gone through multiple proxies which each add their own RR, e.g.

   Record-Route: <sip:proxy1;lr>
   Record-Route: <sip:proxy2;lr>
   Record-Route: <sip:proxy3;lr>

If so, you will need to refer to the appropriate header subscript in
order to extract the domain you really want, i.e. $hdr(name)[N]), as
explained here:

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

SIP also allows the above to be compacted into a single RR header
containing multiple URIs, i.e.

   Record-Route: <sip:proxy1;lr>,<sip:proxy2;lr>,<sip:proxy3;lr>

So a truly bulletproof approach would have to make accommodations for
that scenario as well.

In situations where a given approach can only work for a small subset of
possibilities, I am inclined to ask: what is the real problem you are
trying to solve? Could it perhaps be solved another way?

-- Alex

-- 
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