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?
i need such modifications: User-Agent: FPBX-2.11.0(11.17.1) -> User-Agent: FPBX-2.11.0 (11.17.1) Server: User-Agent: FPBX-2.11.0(11.17.1) -> Server: User-Agent: FPBX-2.11.0 (11.17.1)
Thank you.
-- Best regards, Sergey Basov e-mail: sergey.v.basov@gmail.com
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.remov... 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
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
On Fri, Nov 25, 2016 at 06:55:34PM +0200, Sergey Basov wrote:
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"); } ?
Just remove_hf is enough. is_present_hf/remove_hf might be more readable though.
Hi, All.
One more question related to remove_hf...
I have added route: # Fix user-agent and server route[RemoveHeader] { remove_hf("server"); remove_hf("user-agent"); return; }
I use it form request_route { .... route(RemoveHeader); ..... }
failure_route[--- all what i have ---] { .... route(RemoveHeader); ..... }
branch_route[MANAGE_BRANCH]{ .... route(RemoveHeader); ..... }
onreply_route[MANAGE_REPLY] { .... route(RemoveHeader); ..... }
failure_route[MANAGE_FAILURE] { .... route(RemoveHeader); ..... }
Seems all is fine It removes headers in all packets except 200 OK on BYE.... After debugging script I does not seen in which route this 200 Ok goes.. But if I adding next to route[RELAY] { .... if (is_method("BYE")) { xlog("L_INFO","route RELAY method BYE \n"); if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY_ON_BYE"); } ....... }
and adding route onreply_route[MANAGE_REPLY_ON_BYE] { route(RemoveHeader); xlog("L_INFO","route MANAGE_REPLY_ON_BYE entered \n"); }
this 200 Ok successfully goes to MANAGE_REPLY_ON_BYE route and headers are removed.
Is this configuration correct? I can not find any info regarding parsing 200 OK on BYE in google.
Sorry for long question...
-- Best regards, Sergey Basov e-mail: sergey.v.basov@gmail.com
tel: (+38067) 403-62-54
2016-11-28 11:32 GMT+02:00 Daniel Tryba d.tryba@pocos.nl:
On Fri, Nov 25, 2016 at 06:55:34PM +0200, Sergey Basov wrote:
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"); } ?
Just remove_hf is enough. is_present_hf/remove_hf might be more readable though.
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