[Home]

Summary:ASTERISK-01057: SIP INVITE and To: missing username when using mysql and sipfriends table
Reporter:Rob Gagnon (rgagnon)Labels:
Date Opened:2004-02-19 20:04:31.000-0600Date Closed:2008-01-15 14:44:01.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Cisco ATA186 and other 2-line ATA devices return 404 not found because username missing in To: header of SIP INVITE


****** ADDITIONAL INFORMATION ******


Ex: extension 706 calls ext 704 using sipfriends /mysql

INVITE shows
INVITE sip:10.1.1.1 SIP/2.0
Via........
From: "704" <sip:704@10.2.2.2>;tag=blah
To: <sip:10.1.1.1>

The "706@" in this example is missing, and string should be:
To: <sip:706@10.1.1.1>;tag=blahblah

Proposed solution:
Copy "name" to "username" in the mysql_peer() function as show in this diff:

(also shown in this diff, is the addition of the "nat" field int(2) to the sipfriends table that I needed.  Feel free to use it.  I plan on modifying this more, to support the caller id and other fields from sip.conf as well.


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.296
diff -r1.296 chan_sip.c
720a721
>               int nat;
745a747,748
>                                                       //RG 2004-02-19 Fix Cisco ATA186 404 during INVITE
>                                                       strncpy(p->username, rowval[x], sizeof(p->username) - 1);
756a760,763
>                                               } else if (!strcasecmp(fields[x].name, "nat")) {
>                                                       if (sscanf(rowval[x], "%i", &nat) != 1)
>                                                               nat = 0;
>                                                       p->nat = nat;
775c782
<               p->nat = globalnat;
---
>               //p->nat = globalnat;
6208c6215
<             else if (!strcasecmp(v->name, "dtmfmode")) {
---
>          else if (!strcasecmp(v->name, "dtmfmode")) {
Comments:By: z_smurf (z_smurf) 2004-02-19 21:43:12.000-0600

I confirm that this seems to work, and that it does not break anything for Grandstream-phones.

I will include your fix to my mysql-friend patch in bugnote ASTERISK-1011052

//Andreas

By: Rob Gagnon (rgagnon) 2004-02-20 02:24:28.000-0600

Thanks.  In our lab, we are currently testing with Cisco ATA186, 3Com SIP phone, Grandstream HT286, and various windows and linux based soft sip phones.  In each case, this fixed the problem of using the sipfriends table versus a flat-file config from sip.conf

By: z_smurf (z_smurf) 2004-02-20 05:25:46.000-0600

I think you will need my patch ASTERISK-1011052 too for sipfriend table. The devices times out after 120 seconds, becomes "unregistered" until they register again. This mean noone is able to call the devices during this unregisted period.
There is no way you can see that they time out, but if you do a lot of calls, you will notice that your call wont go trough suddenly.

By: Rob Gagnon (rgagnon) 2004-02-20 10:15:10.000-0600

Yeah.  I saw that patch, and concur with your findings in it.  Thanks for finding that memory leak.  I have seen the msg there appear in our debug logs that indicate the leak.

An interim configuration solution for people could be to put "defaultexpiry=3600" in the "[general]" section of the sip.conf file.

SIDENOTE:  Being new to the buglist, I'm not sure the timing between when a patch is created, and when it is committed to CVS.  Is there a FAQ somewhere that shows things like this?

edited on: 02-20-04 09:06

By: Mark Spencer (markster) 2004-02-20 10:54:45.000-0600

Fixed in CVS, but i added an extra field to the database called "username"

By: Digium Subversion (svnbot) 2008-01-15 14:44:00.000-0600

Repository: asterisk
Revision: 2202

U   trunk/channels/chan_sip.c
U   trunk/contrib/scripts/sip-friends.sql

------------------------------------------------------------------------
r2202 | markster | 2008-01-15 14:43:59 -0600 (Tue, 15 Jan 2008) | 2 lines

Improve SIP friends support (should address bugs ASTERISK-1057 & ASTERISK-1046)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=2202

By: Digium Subversion (svnbot) 2008-01-15 14:44:01.000-0600

Repository: asterisk
Revision: 2203

U   branches/v1-0_stable/channels/chan_sip.c
U   branches/v1-0_stable/contrib/scripts/sip-friends.sql

------------------------------------------------------------------------
r2203 | markster | 2008-01-15 14:44:00 -0600 (Tue, 15 Jan 2008) | 2 lines

Fix some SIP friends issues (bug ASTERISK-1057 & ASTERISK-1046)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=2203