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

Asterisk Bug Tracker noreply at bugs.digium.com
Fri May 22 12:46:19 CDT 2009


The following issue has been UPDATED. 
====================================================================== 
https://issues.asterisk.org/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:                     confirmed
Target Version:             1.4.26
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-05-22 12:46 CDT
====================================================================== 
Summary:                    [patch] 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.

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

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-05-22 12:46 lmadsen        Target Version            => 1.4.26          
======================================================================




More information about the asterisk-bugs mailing list