I think I’ve found an edge case with the string transformations for line.count:
In pv_trans.c, the following code does not appear to consider the last line if there are multiple lines and the last one is not terminated with \n.
case TR_LINE_COUNT: n=0; for(i=0; i<val->rs.len; i++) if(val->rs.s[i]=='\n') n++; if(n==0 && val->rs.len>0) n = 1; val->flags = PV_TYPE_INT|PV_VAL_INT|PV_VAL_STR; val->ri = n; val->rs.s = int2str(val->ri, &val->rs.len); break;
This means that my count is always one off unless I force a blank line at the end of my string.
Also, this code does not cater for cases where there is a different line terminator, such as CR or CRLF as is the case when the string comes from a Mac or windows system, respectively; it might be useful to have a transformation for doing that as I’ve had to hack it using s.replace with hexadecimal escape codes (\r and \n do not work) in a variable.
With every blessing, — Daniel Donoghue
Hello,
can you try with the patch from commit:
* https://github.com/kamailio/kamailio/commit/eaec3aaac227eb4a8c48f93b45565d15...
If works, then I will backport.
The transformation is designed for working with lines in sip message that are terminated with CRLF, by searching for LF (\n) to cover the unix/dos. If you want to remove \r, there is a string trim transformation. I haven't seen lines finished only with \r flowing in the SIP world, but feel free to add new features in the code and propose pull requests via github project portal.
Cheers, Daniel
On 06.10.21 16:45, Daniel Donoghue wrote:
I think I’ve found an edge case with the string transformations for line.count:
In pv_trans.c, the following code does not appear to consider the last line if there are multiple lines and the last one is not terminated with \n.
case TR_LINE_COUNT: n=0; for(i=0; i<val->rs.len; i++) if(val->rs.s[i]=='\n') n++; if(n==0 && val->rs.len>0) n = 1; val->flags = PV_TYPE_INT|PV_VAL_INT|PV_VAL_STR; val->ri = n; val->rs.s = int2str(val->ri, &val->rs.len); break;
This means that my count is always one off unless I force a blank line at the end of my string.
Also, this code does not cater for cases where there is a different line terminator, such as CR or CRLF as is the case when the string comes from a Mac or windows system, respectively; it might be useful to have a transformation for doing that as I’ve had to hack it using s.replace with hexadecimal escape codes (\r and \n do not work) in a variable.
With every blessing, — Daniel Donoghue
Kamailio - Users Mailing List - Non Commercial Discussions
- sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
Hi Daniel,
Thanks for the prompt response.
Unfortunately, I am not in a position to be able to build kamailio from source at the moment, I noticed this issue on our production servers, using prebuilt binaries from apt repos but the code, at first glance, looks like it should work.
We are using a db to inject headers into outbound INVITEs and the db is filled using db tools running on Mac laptops; this means that I have been able to instruct our staff to ensure they press enter at the end of each line. It also means I had to do a fix in kamailio to convert mac’s line terminator, 0x0a, to a linux terminator, 0x0d, in order for the line counting and separation to work at all, which is why I made a suggestion for a new transformation that could do that for us… trim won’t work as the field is multi-line.
Blessings, — Daniel
On 7 Oct 2021, at 09:28, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
can you try with the patch from commit:
- https://github.com/kamailio/kamailio/commit/eaec3aaac227eb4a8c48f93b45565d15... https://github.com/kamailio/kamailio/commit/eaec3aaac227eb4a8c48f93b45565d15d4a0a991
If works, then I will backport.
The transformation is designed for working with lines in sip message that are terminated with CRLF, by searching for LF (\n) to cover the unix/dos. If you want to remove \r, there is a string trim transformation. I haven't seen lines finished only with \r flowing in the SIP world, but feel free to add new features in the code and propose pull requests via github project portal.
Cheers, Daniel
On 06.10.21 16:45, Daniel Donoghue wrote:
I think I’ve found an edge case with the string transformations for line.count:
In pv_trans.c, the following code does not appear to consider the last line if there are multiple lines and the last one is not terminated with \n.
case TR_LINE_COUNT: n=0; for(i=0; i<val->rs.len; i++) if(val->rs.s[i]=='\n') n++; if(n==0 && val->rs.len>0) n = 1; val->flags = PV_TYPE_INT|PV_VAL_INT|PV_VAL_STR; val->ri = n; val->rs.s = int2str(val->ri, &val->rs.len); break;
This means that my count is always one off unless I force a blank line at the end of my string.
Also, this code does not cater for cases where there is a different line terminator, such as CR or CRLF as is the case when the string comes from a Mac or windows system, respectively; it might be useful to have a transformation for doing that as I’ve had to hack it using s.replace with hexadecimal escape codes (\r and \n do not work) in a variable.
With every blessing, — Daniel Donoghue
Kamailio - Users Mailing List - Non Commercial Discussions
- sr-users@lists.kamailio.org mailto:sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
-- Daniel-Constantin Mierla -- www.asipto.com http://www.asipto.com/ www.twitter.com/miconda http://www.twitter.com/miconda -- www.linkedin.com/in/miconda http://www.linkedin.com/in/miconda Kamailio Advanced Training - Online Nov 08-11, 2021 (Europe Timezone) - Nov 22-25, 2021 (America Timezone)
Hi there...
Is there a way for Kamailio to proxy the presence status of items on FreeSWITCH???
for example:
x201 registers via Kamailio and subscribes to the presence of 'Night Mode' (normally, BLF set to *21) Night Mode is on the FreeSWITCH server and toggled by dialing a feature code (*21) How can I get the status of Night Mode sent to the BLFs on x201 when the device is reg'd to Kamailio and not FS ?
Can it be done? (likely but how)
Jerry
Hello,
presence service are decoupled from registration service in SIP. To get notified on a specific event, then the UA has to send a SUBSCRIBE to the presentity for that event. Even the SUBSCRIBE comes to Kamailio, you can route it to another SIP system. It is quite common for Kamailio to handle SUBSCRIBE for user presence event and route SUBSCRIBE for MWI to media server (e.g., Asterisk or FreeSwitch). Just to routing based on Event header conditions.
Cheers, Daniel
On 07.10.21 18:05, Jerry Kendall wrote:
Hi there...
Is there a way for Kamailio to proxy the presence status of items on FreeSWITCH???
for example:
x201 registers via Kamailio and subscribes to the presence of 'Night Mode' (normally, BLF set to *21) Night Mode is on the FreeSWITCH server and toggled by dialing a feature code (*21) How can I get the status of Night Mode sent to the BLFs on x201 when the device is reg'd to Kamailio and not FS ?
Can it be done? (likely but how)
Jerry
Kamailio - Users Mailing List - Non Commercial Discussions * sr-users@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
On 8 Oct 2021, at 08:47, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
presence service are decoupled from registration service in SIP. To get notified on a specific event, then the UA has to send a SUBSCRIBE to the presentity for that event. Even the SUBSCRIBE comes to Kamailio, you can route it to another SIP system. It is quite common for Kamailio to handle SUBSCRIBE for user presence event and route SUBSCRIBE for MWI to media server (e.g., Asterisk or FreeSwitch). Just to routing based on Event header conditions.
For scalability, a media server can PUBLISH events to Kamailio that will handle a large amount of subscribers that get the events.
I think there was some work done in Asterisk to get this done. I had an early implementation many years ago. Don’t know the current state though.
/O
Cheers, Daniel
On 07.10.21 18:05, Jerry Kendall wrote:
Hi there...
Is there a way for Kamailio to proxy the presence status of items on FreeSWITCH???
for example:
x201 registers via Kamailio and subscribes to the presence of 'Night Mode' (normally, BLF set to *21) Night Mode is on the FreeSWITCH server and toggled by dialing a feature code (*21) How can I get the status of Night Mode sent to the BLFs on x201 when the device is reg'd to Kamailio and not FS ?
Can it be done? (likely but how)
Jerry
Kamailio - Users Mailing List - Non Commercial Discussions
- sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
-- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - Online Nov 08-11, 2021 (Europe Timezone) - Nov 22-25, 2021 (America Timezone)
Kamailio - Users Mailing List - Non Commercial Discussions
- sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: