[SR-Users] Parsing diversion headers correctly

Joel Serrano | VOZELIA joel at vozelia.com
Sat Jun 25 03:23:47 CEST 2016


Hi, 

If you receive an INVITE with 2 diversion headers such as (in this order):

Diversion: <sip:9975 at X.X.X.X:5060>;privacy=off;screen=no; reason=user-busy; counter=1
Diversion: <sip:1234567890 at Z.Z.Z.Z:5060>;privacy=off;screen=no; reason=unknown; counter=1

How is a nice way of extracting the user part from the URI of the last one? (in this case: 1234567890)

Problems I have found:

$(di{uri.user}) ---> Give mes the user part of the URI of the first header, in this case: 9975

Is there a way to tell $di to get its value from the last header instead of the first one?


This example works:

$(hdr(Diversion)[-1]{param.name,0}{s.strip,1}{s.striptail,1}{uri.user})

But I think it is very hacky...

Any better approach anyone can suggest me?


Thanks in advance.

Best regards, 
Joel.



More information about the sr-users mailing list