[asterisk-dev] RTCP port always bound to 0.0.0.0?

Tony Mountifield tony at softins.clara.co.uk
Fri Sep 15 06:34:53 MST 2006


I was just looking at the open ports on one of my Asterisk systems
that uses a SIP-based ITSP (IP addresses changed):

[root at aster1 modules]# netstat -nap | grep asterisk
tcp        0      0 127.0.0.1:5038              0.0.0.0:*                   LISTEN      19239/asterisk      
tcp        0      0 127.0.0.1:5038              127.0.0.1:38203             ESTABLISHED 19239/asterisk      
tcp        0      0 127.0.0.1:5038              127.0.0.1:41982             ESTABLISHED 19239/asterisk      
udp        0      0 123.45.678.9:14248          0.0.0.0:*                               19239/asterisk      
udp        0      0 0.0.0.0:14249               0.0.0.0:*                               19239/asterisk      
udp        0      0 123.45.678.9:12082          0.0.0.0:*                               19239/asterisk      
udp        0      0 0.0.0.0:12083               0.0.0.0:*                               19239/asterisk      
udp        0      0 123.45.678.9:5060           0.0.0.0:*                               19239/asterisk      
udp        0    432 123.45.678.9:17488          0.0.0.0:*                               19239/asterisk      
udp        0      0 0.0.0.0:17489               0.0.0.0:*                               19239/asterisk      
udp        0      0 123.45.678.9:4569           0.0.0.0:*                               19239/asterisk      
unix  2      [ ACC ]     STREAM     LISTENING     1222807 19239/asterisk      /var/run/asterisk.ctl
unix  3      [ ]         STREAM     CONNECTED     1586871 19239/asterisk      
[root at aster1 modules]#

I noticed the pairs of ports, which I guessed to be RTP and RTCP ports.
The three pairs corresponded to three SIP channels being open:

[root at aster1 modules]# rasterisk -x 'show channels'
Channel              Location             State   Application(Data)             
SIP/194.54.172.1-086 ssp000059 at meetntalk: Up      MeetMe(mmp000059|diMswRTY)    
SIP/194.54.172.1-086 ssp000059 at meetntalk: Up      MeetMe(mmp000059|diMswRTY)    
Zap/pseudo-636396412 s at default:1          Rsrvd   (None)                        
Zap/pseudo-338724309 s at default:1          Rsrvd   (None)                        
SIP/194.54.172.1-086 smp000059 at meetntalk: Up      MeetMe(mmp000059|aAdiMsRTS(5)U
5 active channels
3 active calls
Verbosity is at least 5
    -- Remote UNIX connection
[root at aster1 modules]#

I wondered why the second port of each pair was bound to 0.0.0.0 instead of
to the local IP address, so I looked in rtp.c at ast_rtp_new_with_bindaddr().
The local address of the RTCP socket doesn't get set anywhere. Should it?

I would be inclined to change this code:

                /* Must be an even port number by RTP spec */
                rtp->us.sin_port = htons(x);
                rtp->us.sin_addr = addr;
                /* If there's rtcp, initialize it as well. */
                if (rtp->rtcp)
                        rtp->rtcp->us.sin_port = htons(x + 1);

to this:

                /* Must be an even port number by RTP spec */
                rtp->us.sin_port = htons(x);
                rtp->us.sin_addr = addr;
                /* If there's rtcp, initialize it as well. */
                if (rtp->rtcp) {
                        rtp->rtcp->us.sin_port = htons(x + 1);
                        rtp->rtcp->us.sin_addr = addr;
                }

Is there a reason not to?

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org


More information about the asterisk-dev mailing list