[asterisk-bugs] [Asterisk 0014756]: Realtime - incorrect set peer ip-address and port after restart

Asterisk Bug Tracker noreply at bugs.digium.com
Thu Mar 26 14:37:51 CDT 2009


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=14756 
====================================================================== 
Reported By:                Alexei Gradinari
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   14756
Category:                   Channels/chan_sip/Registration
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
Asterisk Version:           1.6.0.6 
Regression:                 No 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2009-03-25 15:52 CDT
Last Modified:              2009-03-26 14:37 CDT
====================================================================== 
Summary:                    Realtime - incorrect set peer ip-address and port
after restart
Description: 
After restarting asterisk sets peer ip-address and port based on
fullcontact from database.
I think it's wrong because the SIP Contact may contain NAT inside
ip-address.

For example
if the Contact is sip:TEST707 at 192.168.0.43
After restart asterisk and before SIP peer registers again
SIP peer ip-address and port are incorrect
asterisk -r -x 'sip show peer TEST707 load'
  Addr->IP     : 192.168.0.43 Port 5060
after SIP peer registers
  Addr->IP     : 64.231.137.147 Port 29277

The bug in the function 'sip_peer' in this code
================================================
        if (fullcontact->used > 0) {
                ast_copy_string(peer->fullcontact, fullcontact->str,
sizeof(peer->fullcontact));
                peer->rt_fromcontact = TRUE;
                /* We have a hostname in the fullcontact, but if we don't
have an 
                 * address listed on the entry (or if it's 'dynamic'),
then we need to 
                 * parse the entry to obtain the IP address, so a dynamic
host can be 
                 * contacted immediately after reload (as opposed to
waiting for it to 
                 * register once again). */
                /* XXX May need to revisit the final argument; does the
realtime DB store whether 
                 * the original contact was over TLS or not? XXX */
                __set_address_from_contact(fullcontact->str, &peer->addr,
0);
        }
================================================
The call of function __set_address_from_contact overwrite the peer
ip-address and ports.

I think the code should be 
================================================
        if (fullcontact->used > 0) {
                ast_copy_string(peer->fullcontact, fullcontact->str,
sizeof(peer->fullcontact));
                peer->rt_fromcontact = TRUE;
                if (!(peer->addr.sin_addr..s_addr && peer->addr.sin_port))
{
                    /* We have a hostname in the fullcontact, but if we
don't have an
                     * address listed on the entry (or if it's 'dynamic'),
then we need to
                     * parse the entry to obtain the IP address, so a
dynamic host can be
                     * contacted immediately after reload (as opposed to
waiting for it to
                     * register once again). */
                    /* XXX May need to revisit the final argument; does
the realtime DB store whether
                     * the original contact was over TLS or not? XXX */
                    __set_address_from_contact(fullcontact->str,
&peer->addr, 0);
                }
        }
================================================
So we have to use 'fullcontact' only if peer ip-address or port aren't
set.

====================================================================== 

---------------------------------------------------------------------- 
 (0102255) johann8384 (reporter) - 2009-03-26 14:37
 http://bugs.digium.com/view.php?id=14756#c102255 
---------------------------------------------------------------------- 
I believe I have this exact same issue. I am running an SVN revision of the
1.4 branch. I'll see if this change takes care of the issue. 

One correction:
if (!(peer->addr.sin_addr..s_addr && peer->addr.sin_port)) {
Probably should be:
if (!(peer->addr.sin_addr.s_addr && peer->addr.sin_port)) { 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-03-26 14:37 johann8384     Note Added: 0102255                          
======================================================================




More information about the asterisk-bugs mailing list