Thank you Daniel.

Is it safe to use remove_hf("User-Agent") without check if this header exist?
or better use if(is_present_hf("User-Agent")) { remove_hf("User-Agent"); } ?

Thank you.

25 нояб. 2016 г. 2:56 PM пользователь "Daniel Tryba" <d.tryba@pocos.nl> написал:
On Fri, Nov 25, 2016 at 02:08:07PM +0200, Sergey Basov wrote:
> Hello All.
>
> I have some troubles with upstream sip switch.
> It ignores SIP packets which contains:
>
> User-Agent: FPBX-2.11.0(11.17.1)
> or
> Server: User-Agent: FPBX-2.11.0(11.17.1)
>
> If space is present before first "(" then sip switch works as expected
>
> So my question is: how corektly make analyze and modify this headers
> using kamailio?
> In which routes i must parse it?

Since you need to remove the headers first before replacing it if you
wish, you'll need the textops remove_hf function:
http://kamailio.org/docs/modules/stable/modules/textops.html#textops.f.remove_hf
which can be used in REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE and
BRANCH_ROUTE.

If you really want to bother to change these headers you could do
something like

$var(ua)=$hdr(User-Agent);
$var(ua)=$(var(ua){re.subst,/(.*)(\(.*\))(.*)/\1 \2\3/});
remove_hf("User-Agent");
append_hf("USer-Agent: $var(ua)\r\n");

Which blindly replaces the "(foo)" string by " (foo)" regardless of the
char before the first "(".

But use the KISS approach: just delete the headers

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users