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

Asterisk Bug Tracker noreply at bugs.digium.com
Sun Mar 29 14:55:45 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:                     feedback
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-29 14:55 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.

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

---------------------------------------------------------------------- 
 (0102360) Alexei Gradinari (reporter) - 2009-03-29 14:55
 http://bugs.digium.com/view.php?id=14756#c102360 
---------------------------------------------------------------------- 
I've attached patch chan_sip_fullcontact.patch 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-03-29 14:55 Alexei GradinariNote Added: 0102360                          
======================================================================




More information about the asterisk-bugs mailing list