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.remo…
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