Given a Diversion header like the following:
``` Diversion:"Foo Bar"sip:+9876543211@127.0.0.101;user=phone;privacy=off;answered-count=2;re ason=deflection;counter=1;answered,"_ somewhere"sip:+9876543212@127.0.0.101;user=phone;privacy=off;answered-coun t=1;reason=deflection;counter=1;answered ```
Kamailio 4.4.3 (and probably earlier versions) emit error messages complaining about the comma character. According to RFC 6044 multiple comma-separated diversions in a single Diversion-header is allowed.
Full INVITE as an example:
``` INVITE sip:+1234567890@127.0.0.100:5060;user=phone;transport=tcp SIP/2.0 Via:SIP/2.0/TCP 127.0.0.101;branch=z9hG4bKBroadWorks.-1od4eg8-127.0.0.100V5060-0-82844591-13 54681939-1477634439005- From:sip:+9876543210@127.0.0.101;user=phone;tag=1354681939-1477634439005- To:sip:+1234567890@127.0.0.100:5060;user=phone Call-ID:BW0800390052810161562691307@127.0.0.101 CSeq:82844591 INVITE Contact:sip:127.0.0.101:5060;transport=tcp P-Asserted-Identity:sip:+9876543210@127.0.0.101;user=phone Privacy:none Diversion:"Foo Bar"sip:+9876543211@127.0.0.101;user=phone;privacy=off;answered-count=2;re ason=deflection;counter=1;answered,"_ somewhere"sip:+9876543212@127.0.0.101;user=phone;privacy=off;answered-coun t=1;reason=deflection;counter=1;answered Supported:100rel Allow:ACK,BYE,CANCEL,INFO,INVITE,OPTIONS,PRACK,REFER,NOTIFY,UPDATE X-BroadWorks-DNC:network-address="sip:+9876543210@127.0.0.101;user=phone" Accept:application/dtmf-relay,application/media_control+xml,application/sdp, application/x-broadworks-call-center+xml,multipart/mixed Max-Forwards:10 Content-Type:application/sdp Content-Disposition:session;handling=required Content-Length:267
v=0 o=BroadWorks 100442303 1 IN IP4 127.0.0.101 s=- c=IN IP4 127.0.0.102 t=0 0 m=audio 29778 RTP/AVP 8 0 18 101 a=rtpmap:8 PCMA/8000 a=rtpmap:0 PCMU/8000 a=rtpmap:18 G729/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=sendrecv a=maxptime:20 ```
Example log messages:
``` Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [parser/parse_addr_spec.c:488]: parse_to_param(): ERROR parse_to_param : invalid character ',' in status 21: <<;privacy=off;answered-count=2;reason=deflection;counter=1;answered>> Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [parser/parse_addr_spec.c:254]: parse_to_param(): ERROR: parse_to_param :unexpected char ["] in status 21: <<;privacy=off;answered-count=2;reason=deflection;counter=1;answered,>> . Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [parser/parse_addr_spec.c:906]: parse_addr_spec(): ERROR: parse_to: invalid To - unexpected end of header in state 21 Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [parser/parse_diversion.c:69]: parse_diversion_header(): ERROR:parse_diversion_header: bad diversion header Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [lvalue.c:345]: lval_pvar_assign(): non existing right pvar Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [lvalue.c:405]: lval_assign(): assignment failed at pos: (562,21-562,35)
``` The code on line 562 is `$avp(div_user) = $(di{uri.user});`.
kamailio -v:
```version: kamailio 4.4.3 (x86_64/linux) flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: unknown compiled with gcc 4.7.2```
uname -a:
`Linux hostname 3.2.0-4-amd64 #1 SMP Debian 3.2.81-2 x86_64 GNU/Linux`
Hi,
You are reffering to an obsolete RFC, a replacement is rfc5806
Regards,
On Tue, Nov 1, 2016 at 4:00 PM, Björn Bylander notifications@github.com wrote:
Given a Diversion header like the following:
Diversion:"Foo Bar"sip:+9876543211@127.0.0.101;user=phone;privacy=off;answered-count=2;re ason=deflection;counter=1;answered,"_ somewhere"sip:+9876543212@127.0.0.101;user=phone;privacy=off;answered-coun t=1;reason=deflection;counter=1;answered
Kamailio 4.4.3 (and probably earlier versions) emit error messages complaining about the comma character. According to RFC 6044 multiple comma-separated diversions in a single Diversion-header is allowed.
Full INVITE as an example:
INVITE sip:+1234567890@127.0.0.100:5060;user=phone;transport=tcp SIP/2.0 Via:SIP/2.0/TCP 127.0.0.101;branch=z9hG4bKBroadWorks.-1od4eg8-127.0.0.100V5060-0-82844591-13 54681939-1477634439005- From:sip:+9876543210@127.0.0.101;user=phone;tag=1354681939-1477634439005- To:sip:+1234567890@127.0.0.100:5060;user=phone Call-ID:BW0800390052810161562691307@127.0.0.101 CSeq:82844591 INVITE Contact:sip:127.0.0.101:5060;transport=tcp P-Asserted-Identity:sip:+9876543210@127.0.0.101;user=phone Privacy:none Diversion:"Foo Bar"sip:+9876543211@127.0.0.101;user=phone;privacy=off;answered-count=2;re ason=deflection;counter=1;answered,"_ somewhere"sip:+9876543212@127.0.0.101;user=phone;privacy=off;answered-coun t=1;reason=deflection;counter=1;answered Supported:100rel Allow:ACK,BYE,CANCEL,INFO,INVITE,OPTIONS,PRACK,REFER,NOTIFY,UPDATE X-BroadWorks-DNC:network-address="sip:+9876543210@127.0.0.101;user=phone" Accept:application/dtmf-relay,application/media_control+xml,application/sdp, application/x-broadworks-call-center+xml,multipart/mixed Max-Forwards:10 Content-Type:application/sdp Content-Disposition:session;handling=required Content-Length:267
v=0 o=BroadWorks 100442303 1 IN IP4 127.0.0.101 s=- c=IN IP4 127.0.0.102 t=0 0 m=audio 29778 RTP/AVP 8 0 18 101 a=rtpmap:8 PCMA/8000 a=rtpmap:0 PCMU/8000 a=rtpmap:18 G729/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=sendrecv a=maxptime:20
Example log messages:
Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [parser/parse_addr_spec.c:488]: parse_to_param(): ERROR parse_to_param : invalid character ',' in status 21: <<;privacy=off;answered-count=2;reason=deflection;counter=1;answered>> Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [parser/parse_addr_spec.c:254]: parse_to_param(): ERROR: parse_to_param :unexpected char ["] in status 21: <<;privacy=off;answered-count=2;reason=deflection;counter=1;answered,>> . Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [parser/parse_addr_spec.c:906]: parse_addr_spec(): ERROR: parse_to: invalid To - unexpected end of header in state 21 Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [parser/parse_diversion.c:69]: parse_diversion_header(): ERROR:parse_diversion_header: bad diversion header Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [lvalue.c:345]: lval_pvar_assign(): non existing right pvar Oct 28 08:00:39 kam1 /usr/sbin/kamailio[14935]: ERROR: <core> [lvalue.c:405]: lval_assign(): assignment failed at pos: (562,21-562,35)
The code on line 562 is $avp(div_user) = $(di{uri.user});.
kamailio -v:
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: unknown compiled with gcc 4.7.2```
uname -a:
`Linux hostname 3.2.0-4-amd64 #1 SMP Debian 3.2.81-2 x86_64 GNU/Linux`
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kamailio/kamailio/issues/841, or mute the thread https://github.com/notifications/unsubscribe-auth/AF36ZdODVt-4LXUU61bER1Wq_ZJomUBGks5q51QVgaJpZM4KmL3j .
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Hmm, isn't RFC 5806 (March 2010) older than RFC 6044 (October 2010)? Given that, I fail to see how 5806 can be a replacement? RFC 6044 is obsoleted by RFC 7544 however (August 2015) which also says that comma separated diversions are allowed.
If I remember well this header never becomes an proposed standard (i might be wrong) and for these cases as most popular the draft most implemented.
Regards,
On Nov 1, 2016 9:26 PM, "Björn Bylander" notifications@github.com wrote:
Hmm, isn't RFC 5806 (March 2010) older than RFC 6044 (October 2010)? Given that, I fail to see how 5806 can be a replacement? RFC 6044 is obsoleted by RFC 7544 however (August 2015) which also says that comma separated diversions are allowed.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kamailio/kamailio/issues/841#issuecomment-257684840, or mute the thread https://github.com/notifications/unsubscribe-auth/AF36ZbDUFnVB1KMKp_K4sfefOLr0cc4Xks5q56BogaJpZM4KmL3j .
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
You're correct in that it's obsoleted and History-Info is the solution adopted by IETF but the Diversion header is far from obsolete in practice as it's used by major IP telephony system providers like Broadsoft and Sonus and probably quite a few more. In addition, Kamailio has the Diversion module specifically for this header.
"*The module implements the Diversion extensions as per RFC 5806*. The diversion extensions are useful in various scenarios involving call forwarding. Typically one needs to communicate the original recipient of the call to the PSTN gateway and this is what the diversion extensions can be used for."
From 'https://www.kamailio.org/docs/modules/4.3.x/modules/diversion.html'
On Tue, Nov 1, 2016 at 9:36 PM, Björn Bylander notifications@github.com wrote:
You're correct in that it's obsoleted and History-Info is the solution adopted by IETF but the Diversion header is far from obsolete in practice as it's used by major IP telephony system providers like Broadsoft and Sonus and probably quite a few more. In addition, Kamailio has the Diversion module specifically for this header.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kamailio/kamailio/issues/841#issuecomment-257687485, or mute the thread https://github.com/notifications/unsubscribe-auth/AF36ZRvey1O-thity-uEjboinsgYFPSMks5q56KygaJpZM4KmL3j .
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Sure. But why can't Kamailio (the Diversion module or whatever it would affect) be extended to support newer RFCs as long as it doesn't break backwards compatibility? I'm not necessarily reporting a bug, it's more of a feature request.
I think Kamailio has generic code in the core parser to handle multiple header values in a header. That is a generic construct in the SIP protocol (probably inherited from SMTP). I think it is indeed a bug that the Diversion module does not support this. While waiting for someone to patch I'm pretty sure you can implement what you need with some clever code and transformations.
The discussion about Diversion and History-Info is a separate issue, not related to this bug - in my view.
Hmm. I think I misunderstood where the problem is. This is not the diversion module generating the error messages. YOu're doing something else in your script that parses the header value. This points to the parse_diversion support in the generic parser. I would like to know what code in your config that parses this header.
@oej - it is the diversion variable, see the first comment in this issue.
I pushed a patch that should deal with this situation and retrieve the first diversion value. However, this may need to be turned into an array for full flexibility, that will require more work. Meanwhile, the transformations can be used to get a body by index.
Patch was also backported to branch 4.4 - testing and reporting back the results would be appreciated.
@miconda I've tested it with $(di{uri.user}); on the 4.4 branch and it works.
Meanwhile, the transformations can be used to get a body by index.
@miconda - I'd appreciate a quick code sample to further explain. With "body", do you mean the message body or something else?
Closed #841.
@loxybjorn - thanks, I will close this issue.
The example to get the body of diversion at index 0 was provided in the response to your email on sr-users:
* http://lists.sip-router.org/pipermail/sr-users/2016-October/094931.html