Summary:ASTERISK-06498: Asterisk is not constructing the BYE request RURI correctly from contact headers in some situations.
Reporter:aubergine (aubergine)Labels:
Date Opened:2006-03-07 18:23:31.000-0600Date Closed:2006-04-07 03:20:37
Versions:Frequency of
Environment:Attachments:( 0) bug_6674.txt
Description:For the situation where * send the initial INVITE it constructs the
RURI for the BYE from the contact header of the 200 OK response which is
well and good. However when * receives the initial INVITE it does not
use the contact header contained within to construct the BYE's RURI but
constructs it from scratch. This is of particular concern when one is
using a SIP clients that only do TCP like office communicator (and of
course a proxy in the middle to do UDP/TCP protocol conversion) . In
these cases well-behaving UA puts a transport=tcp tag into the contact
header of either the INVITE or the 200 OK. In the first scenario this
tag is preserved and the BYE's RURI has the transport tag (which the
proxy can use for protocol conversion). The second scenario loses the
transport tag in the BYE's RURI (and the proxy has no idea that protocol
conversion is needed)


parse_ok_contact() is only called from handle_response_invite() which is called when * gets a 200 OK from an INVITE. This handle the above first scenario correctly

I naively add a parse_ok_contact() to handle_request() ie:

       case SIP_INVITE:
               parse_ok_contact(p, req);
               res = handle_request_invite(p, req, debug, ignore, seqno, sin, recount, e);

and this seems to handles the second scenario correctly. However parse_ok_contact() does a lot more than populate p->okcontacturi
Comments:By: Olle Johansson (oej) 2006-03-08 07:02:02.000-0600

Please try this patch. I haven't tested it, so I am grateful for any tests, debug logs etc.

By: mikma (mikma) 2006-03-10 12:06:59.000-0600

I'm also being hit by this bug when I call Asterisk via Openser and the calling UA is connected to Openser with TLS and has included ";transport=TLS" in the Contact uri. The following small patch seems to solve the problem. What's the reason to remove the uri parameters from the Contact uri?

--- channels/chan_sip.c (revision 12340)
+++ channels/chan_sip.c (arbetskopia)
@@ -5007,9 +5030,9 @@
       char *c, *n;
       ast_copy_string(stripped, get_header(req, "Contact"), sizeof(stripped));        c = get_in_brackets(stripped);
-       n = strchr(c, ';');
-       if (n)
-               *n = '\0';
+/*     n = strchr(c, ';'); */
+/*     if (n) */
+/*             *n = '\0'; */
       if (!ast_strlen_zero(c))
               ast_string_field_set(p, uri, c);

By: aubergine (aubergine) 2006-03-13 18:17:28.000-0600

What version is this patch against?

By: aubergine (aubergine) 2006-03-14 01:33:39.000-0600

I've patched 1.2.3 and it appears to be working. Also FYI set_adddress_from_contact() has too many 'd's. Thanks for the patch

By: Olle Johansson (oej) 2006-04-07 03:20:07

Committed to svn trunk. Thanks for testing.