Search code examples
parameterssipkamailio

How to retrieve custom parameter value from SIP contact header in KAMAILIO?


I am using Kamailio 4.4 and I am sending custom parameters with Contact header from my client extensions. the header send to Kamailio is like this

Contact: "Test" <sip:[email protected]:46666;pn-d=android;pn-t=d1eCzkw9bhk:APA91bFntzV>  

I need to extract the value of these two parameters pn-d and pn-t. I tried with the code given below.

$var(pn-d_value) = $sel(contact.uri.params[pn-d]);

but the value can't be retrieved.

Please suggest a way to get the value of custom parameters.


Solution

  • I could resolve this problem using two steps.
    First, you need to extract the URI from the header and store the result into a variable.

    $var(uri) = $sel(contact.uri);
    

    Then you can use transformation on this uri to get the parameter value. like this

    $var(pn-d_value) = $(var(uri){uri.param,pn-d}); //got "android" here
    $var(pn-t_value) = $(var(uri){uri.param,pn-t}); //got "d1eCzkw9bhk:APA91bFntzV" here