Hi,
I am currently trying to understand some kamailio code and came across this construct inside do_forward_reply() function (code in italics is not part of upstream kamailio):
*do_forward_reply(struct sip_msg* msg, int mode){* ... ... apply_force_send_socket(&dst, msg);
if (msg_send(&dst, new_buf, new_len)<0) { STATS_RPL_FWD_DROP(); goto error; } /* ... dst.send_sock=get_send_socket(msg, &dst.to, dst.proto); ... run_onsend(msg, &dst, new_buf, new_len);*/ *}*
Is there really a sense in calling run_onsend() after the msg_send() function? In my understanding (based on onsend_route uasge) run_onsend() is used to make some last minute changes before a message is sent to a destination.
Thank you, Lucian Balaceanu
Hello,
the reason for onsend_route was to get access to outgoing buffer (what is sent to network) as well as the local socket and remote socket attributes (proto, ip, port). There is no option to make changes on the outgoing buffer anymore, the action that could be done is stop sending to the network (discarding).
It was done for requests, but there were discussions to make this available for replies as well. The code you provided in not in public repository, but it seems it aims for that (at least for stateless replies). The onsend callback should be indeed called before msg_send() to get the behavior expected (to be able to drop the reply, for example).
If you get a patch to have the onsend_route for replies, it would be welcomed on the public repo.
Cheers, Daniel
On 04/08/14 15:57, Lucian Balaceanu wrote:
Hi,
I am currently trying to understand some kamailio code and came across this construct inside do_forward_reply() function (code in italics is not part of upstream kamailio):
*do_forward_reply(struct sip_msg* msg, int mode){* ... ... apply_force_send_socket(&dst, msg);
if (msg_send(&dst, new_buf, new_len)<0) { STATS_RPL_FWD_DROP(); goto error; }
/* ... dst.send_sock=get_send_socket(msg, &dst.to, dst.proto); ... run_onsend(msg, &dst, new_buf, new_len);*/ *}*
Is there really a sense in calling run_onsend() after the msg_send() function? In my understanding (based on onsend_route uasge) run_onsend() is used to make some last minute changes before a message is sent to a destination.
Thank you, Lucian Balaceanu
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Hi,
In response to the previous mail, I have attempted to create a suitable patch for calling onsend_route in the replies. However, I need some input from somebody more knowledgeable.
You will find I changed the following code locations:
forward.c -> do_forward_reply() function sl_funcs.c -> sl_reply_helper() function t_reply.c -> _reply_light() function
Am I missing out any location where the onsend function should be called? I am particularly thinking of such cases as relayed replies, retransmitted replies (t_retransmit_reply).
Additionally, in t_reply.c, I force the parsing of the message buffer into a sip_msg; do you see this as a perceivable slowdown in general kamailio performance?
Any input is valuable.
Thank you, Lucian
On 08/04/2014 05:16 PM, Daniel-Constantin Mierla wrote:
Hello,
the reason for onsend_route was to get access to outgoing buffer (what is sent to network) as well as the local socket and remote socket attributes (proto, ip, port). There is no option to make changes on the outgoing buffer anymore, the action that could be done is stop sending to the network (discarding).
It was done for requests, but there were discussions to make this available for replies as well. The code you provided in not in public repository, but it seems it aims for that (at least for stateless replies). The onsend callback should be indeed called before msg_send() to get the behavior expected (to be able to drop the reply, for example).
If you get a patch to have the onsend_route for replies, it would be welcomed on the public repo.
Cheers, Daniel
On 04/08/14 15:57, Lucian Balaceanu wrote:
Hi,
I am currently trying to understand some kamailio code and came across this construct inside do_forward_reply() function (code in italics is not part of upstream kamailio):
*do_forward_reply(struct sip_msg* msg, int mode){* ... ... apply_force_send_socket(&dst, msg);
if (msg_send(&dst, new_buf, new_len)<0) { STATS_RPL_FWD_DROP(); goto error; }
/* ... dst.send_sock=get_send_socket(msg, &dst.to, dst.proto); ... run_onsend(msg, &dst, new_buf, new_len);*/ *}*
Is there really a sense in calling run_onsend() after the msg_send() function? In my understanding (based on onsend_route uasge) run_onsend() is used to make some last minute changes before a message is sent to a destination.
Thank you, Lucian Balaceanu
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
-- Daniel-Constantin Mierla -http://www.asipto.com http://twitter.com/#!/miconda -http://www.linkedin.com/in/miconda
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Hello,
parsing should be done only if the onsend route is enabled:
- perhaps would be good to add a define in onsend.h, not to hardcode in other modules the test on onsend_rt.rlist, like:
#define onsend_enabled() (onsend_rt.rlist[DEFAULT_RT]?1:0)
From performances point of view, there can be added a config parameter to enable running of onsend_route for replies:
onsend_route_reply = 0|1
#define onsend_enabled(rtype) (onsend_rt.rlist[DEFAULT_RT]?((rtype==SIP_REPLY)?onsend_route_reply:1):0)
On the other hand, is onsend_route also executed for local requests? I had in mind it is only for received requests that are forwarded ... Iirc, on onsend_route, the sip message is the one received, the outgoing content being accessible via $snd(buf).
Cheers, Daniel
On 27/08/14 13:19, Lucian Balaceanu wrote:
Hi,
In response to the previous mail, I have attempted to create a suitable patch for calling onsend_route in the replies. However, I need some input from somebody more knowledgeable.
You will find I changed the following code locations:
forward.c -> do_forward_reply() function sl_funcs.c -> sl_reply_helper() function t_reply.c -> _reply_light() function
Am I missing out any location where the onsend function should be called? I am particularly thinking of such cases as relayed replies, retransmitted replies (t_retransmit_reply).
Additionally, in t_reply.c, I force the parsing of the message buffer into a sip_msg; do you see this as a perceivable slowdown in general kamailio performance?
Any input is valuable.
Thank you, Lucian
On 08/04/2014 05:16 PM, Daniel-Constantin Mierla wrote:
Hello,
the reason for onsend_route was to get access to outgoing buffer (what is sent to network) as well as the local socket and remote socket attributes (proto, ip, port). There is no option to make changes on the outgoing buffer anymore, the action that could be done is stop sending to the network (discarding).
It was done for requests, but there were discussions to make this available for replies as well. The code you provided in not in public repository, but it seems it aims for that (at least for stateless replies). The onsend callback should be indeed called before msg_send() to get the behavior expected (to be able to drop the reply, for example).
If you get a patch to have the onsend_route for replies, it would be welcomed on the public repo.
Cheers, Daniel
On 04/08/14 15:57, Lucian Balaceanu wrote:
Hi,
I am currently trying to understand some kamailio code and came across this construct inside do_forward_reply() function (code in italics is not part of upstream kamailio):
*do_forward_reply(struct sip_msg* msg, int mode){* ... ... apply_force_send_socket(&dst, msg);
if (msg_send(&dst, new_buf, new_len)<0) { STATS_RPL_FWD_DROP(); goto error; }
/* ... dst.send_sock=get_send_socket(msg, &dst.to, dst.proto); ... run_onsend(msg, &dst, new_buf, new_len);*/ *}*
Is there really a sense in calling run_onsend() after the msg_send() function? In my understanding (based on onsend_route uasge) run_onsend() is used to make some last minute changes before a message is sent to a destination.
Thank you, Lucian Balaceanu
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
-- Daniel-Constantin Mierla -http://www.asipto.com http://twitter.com/#!/miconda -http://www.linkedin.com/in/miconda
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Hi Daniel,
Please forgive me for my delay in responding to your mail. Please find attached a second version of the onsend_route_reply patch (which again has some problems). As per your previous indications I did the following:
*Issue1*
From performances point of view, there can be added a config parameter to enable running of onsend_route for replies:
onsend_route_reply = 0|1
Following http://www.asipto.com/pub/kamailio-devel-guide/#c08add_parameters I have tried to add onsend_route_reply parameter. The code compiles, but when trying to start kamailio with this parameter inside, the parsing fails with syntax errors signaling:
/ 0(1321) :<core> [cfg.y:3423]: yyerror_at(): parse error in config file kamailio-basic.cfg.4.1, from line 107, column 1 to line 108, column 0: syntax error 0(1321) : <core> [cfg.y:3423]: yyerror_at(): parse error in config file kamailio-basic.cfg.4.1, from line 107, column 1 to line 108, column 0: ERROR: bad config file (2 errors)/
*Issue2*
#define onsend_enabled(rtype) (onsend_rt.rlist[DEFAULT_RT]?((rtype==SIP_REPLY)?onsend_route_reply:1):0)
That is to say you see it best to take the chek for onsend_rt.list[DEFAULT_RT] from inside run_onsend() function and call this onsend_enabled(...) before the run_onsend()?
*Issue3*
On the other hand, is onsend_route also executed for local requests? I had in mind it is only for received requests that are forwarded ... Iirc, on onsend_route, the sip message is the one received, the outgoing content being accessible via $snd(buf).
I agree with you with taking out the locally generated requests and only left the run_onsend call in do_forward_reply function (inside forward.c). Could you point me to the reply relaying function that is called for state-full processing?
Thank you and sorry again for my late answer, Lucian
Hi Lucian,
somehow I forgot to follow up on this. But we need to get sorted out soon, before we release, so it works as expected with the new version. See more comments inline.
On 17/09/14 18:09, Lucian Balaceanu wrote:
Hi Daniel,
Please forgive me for my delay in responding to your mail. Please find attached a second version of the onsend_route_reply patch (which again has some problems). As per your previous indications I did the following:
*Issue1*
From performances point of view, there can be added a config parameter to enable running of onsend_route for replies:
onsend_route_reply = 0|1
Following http://www.asipto.com/pub/kamailio-devel-guide/#c08add_parameters I have tried to add onsend_route_reply parameter. The code compiles, but when trying to start kamailio with this parameter inside, the parsing fails with syntax errors signaling:
/ 0(1321) :<core> [cfg.y:3423]: yyerror_at(): parse error in config file kamailio-basic.cfg.4.1, from line 107, column 1 to line 108, column 0: syntax error 0(1321) : <core> [cfg.y:3423]: yyerror_at(): parse error in config file kamailio-basic.cfg.4.1, from line 107, column 1 to line 108, column 0: ERROR: bad config file (2 errors)/
The issue is:
+<INITIAL>{ONSEND_RT_REPLY} { yylval.intval=atoi(yytext); + yy_number_str=yytext; return NUMBER; }
It should be:
+<INITIAL>{ONSEND_RT_REPLY} { yylval.intval=atoi(yytext); + yy_number_str=yytext; return ONSEND_RT_REPLY; }
*Issue2*
#define onsend_enabled(rtype) (onsend_rt.rlist[DEFAULT_RT]?((rtype==SIP_REPLY)?onsend_route_reply:1):0)
That is to say you see it best to take the chek for onsend_rt.list[DEFAULT_RT] from inside run_onsend() function and call this onsend_enabled(...) before the run_onsend()?
This is to detect whether the onsend_route should be executed for SIP replies. The condition being:
- if is a sip reply and onsend_route is set and the onsend_route_reply parameter is 1
*Issue3*
On the other hand, is onsend_route also executed for local requests? I had in mind it is only for received requests that are forwarded ... Iirc, on onsend_route, the sip message is the one received, the outgoing content being accessible via $snd(buf).
I agree with you with taking out the locally generated requests and only left the run_onsend call in do_forward_reply function (inside forward.c). Could you point me to the reply relaying function that is called for state-full processing?
Stateful processing for replies is mainly done in t_reply.c from tm module. At some point there should be a send buffer function call.
Cheers, Daniel
Thank you and sorry again for my late answer, Lucian