[SR-Users] How do I make subst_hf() use variables in search (not replacement)?

Daniel-Constantin Mierla miconda at gmail.com
Mon Aug 11 09:30:50 CEST 2014


I haven't looked at the code, but probably the function doesn't accept 
variable for the matching regular expression.

If the IP/port of asterisk are not changed, you can try:

#!substdef "/ASTERISKIP/127.0.0.1/"
#!substdef "/ASTERISKPORT/5080/"

asterisk.bindip = "ASTERISKIP" ...
asterisk.bindport = ASTERISKPORT ...

subst_hf("Contact", "/ASTERISKIP:ASTERISKPORT/$td/", "a");

Cheers,
Daniel

On 08/08/14 23:38, Alex Villací­s Lasso wrote:
> Consider the following snippet:
>
> if (is_present_hf("Contact")) {
>         xlog("L_ALERT", "===== reply to SUBSCRIBE has Contact: $ct\n");
>         xlog("L_ALERT", "===== want to replace with $td\n");
>         xlog("L_ALERT", "===== regexp to use is 
> /$sel(cfg_get.asterisk.bindip):$sel(cfg_get.asterisk.bindport)/$td/\n");
>         if (subst_hf("Contact", "/127.0.0.1:5080/$td/", "a")) {
>                 xlog("L_ALERT", "===== reply had Contact modified\n");
>         }
> }
>
> If I use the hardcoded regexp "/127.0.0.1:5080/$td/", subst_hf() 
> replaces the Contact value correctly.
>
> However, if I use 
> "/$sel(cfg_get.asterisk.bindip):$sel(cfg_get.asterisk.bindport)/$td/" 
> (where asterisk.bindip and asterisk.bindport are the supposed values 
> 127.0.0.1 and 5080), subst_hf() fails to replace the Contact value.
>
> How do I make use of the existing configuration variables in order to 
> substitute in the Contact header?
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany ::: Oct 15-17, San Francisco, USA




More information about the sr-users mailing list