Summary:ASTERISK-06558: qualify not working with UIP200 phones unless nat=never is in the global section of sip.conf
Reporter:John Lemons (jlemons)Labels:
Date Opened:2006-03-16 11:06:04.000-0600Date Closed:2006-03-27 17:50:31.000-0600
Versions:Frequency of
Environment:Attachments:( 0) asterisk_sip_debug.txt
( 1) asterisk_sip_show_peer.txt
( 2) chan_sip.c.diff
Description:chan_sip.c has a work-around for some buggy firmware on the UIP200 sip phones.  

in chan_sip.c:build_via
       if (ast_test_flag(p, SIP_NAT) & SIP_NAT_RFC3581)
               snprintf(buf, len, "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport"
       else /* Work around buggy UNIDEN UIP200 firmware */
               snprintf(buf, len, "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_

That work around seems to work fine in Asterisk 1.0.7, but appears broken in Asterisk 1.2.5.

I can recreate the problem by doing the following:
 in sip.conf, remove the nat= line from [global]
 add nat=never to [uip200-1]
 add qualify=yes (or a time, but not no) to [uip200-1]

If I'm reading this right, that config should trigger the work-around, and does, but doesn't.  When debugging the code, I see it use the "if" case the first time, then use the "else" case right after that.  The "if" case causes a failure due to the buggy UIP200, and * makes the phone UNAVAILABLE.  

I can fix it by doing the following:
 in sip.conf, add nat=never to [global]

Debugging the code, I then see that it only calls the "else" case, and the phone responds fine, and qualify works.  

So, it appears to generate the qualify message based on the global nat setting first, then the local setting.

Comments:By: John Lemons (jlemons) 2006-03-16 11:07:49.000-0600

Sorry, [global] should read [general]

By: Olle Johansson (oej) 2006-03-16 11:18:15.000-0600

As requested by the bug guidelines, you need to upload a debug file with a failed session. Set debug to 4, verbose to 4, turn on sip history and sip debug. Thanks.

By: John Lemons (jlemons) 2006-03-16 11:37:06.000-0600

Thanks for the reminder.  I'm new at this so please let me know if that is sufficient information.  I can recreate it reliably, so I can provide whatever feedback you need.

By: Olle Johansson (oej) 2006-03-16 11:41:21.000-0600

Please run "sip show peer <name>" with the two different settings and tell me the difference. Thanks

By: John Lemons (jlemons) 2006-03-16 11:48:52.000-0600

Should I have let it go UNREACHABLE before I ran the "show peer"?

By: Olle Johansson (oej) 2006-03-16 13:13:32.000-0600

That does not matter. I am interested in the nat setting

By: Andrey S Pankov (casper) 2006-03-19 17:05:00.000-0600

The source of the problem is that we don't call create_addr_from_peer after sip_alloc call and SIP_FLAGS_TO_COPY are not copied from peer entry to sip_pvt structure. The patch fixes the issue. Disclaimer is on file.

By: Andrey S Pankov (casper) 2006-03-19 17:09:10.000-0600

The patch is against trunk branch, but applies (with a warning) on 1.2 as well...

By: John Lemons (jlemons) 2006-03-20 12:38:31.000-0600

I just build a version with the patch, and it appears to be working great.

Thanks for the help!

By: Andrey S Pankov (casper) 2006-03-23 14:16:11.000-0600

oej: any chance you submit this to svn? :)

By: Olle Johansson (oej) 2006-03-27 17:50:01.000-0600

Fixed in 1.2 rev 15381, trunk 15382. Thanks for the patch, Casper!