Index: rtp.c =================================================================== RCS file: /usr/cvsroot/asterisk/rtp.c,v retrieving revision 1.66 diff -u -r1.66 rtp.c --- rtp.c 15 May 2004 16:26:52 -0000 1.66 +++ rtp.c 17 May 2004 19:35:32 -0000 @@ -34,6 +34,7 @@ #include #include #include +#include #define RTP_MTU 1200 @@ -45,6 +46,7 @@ static int dtmftimeout = 3000; /* 3000 samples */ +static struct sockaddr_in interface; static int rtpstart = 0; static int rtpend = 0; @@ -786,6 +788,9 @@ } flags = fcntl(rtp->s, F_GETFL); fcntl(rtp->s, F_SETFL, flags | O_NONBLOCK); + memcpy(&rtp->us.sin_addr, &interface.sin_addr, sizeof(rtp->us.sin_addr)); + if (rtp->rtcp) + memcpy(&rtp->rtcp->us.sin_addr, &interface.sin_addr, sizeof(rtp->us.sin_addr)); /* Find us a place */ x = (rand() % (rtpend-rtpstart)) + rtpstart; x = x & ~1; @@ -1428,10 +1438,19 @@ { struct ast_config *cfg; char *s; - rtpstart = 5000; + rtpstart = 8000; rtpend = 31000; cfg = ast_load("rtp.conf"); if (cfg) { + if ((s = ast_variable_retrieve(cfg, "general", "bindaddr"))) { + struct ast_hostent ahp; + struct hostent *hp; + memset(&interface, 0, sizeof(interface)); + if ( (hp = ast_gethostbyname(s, &ahp)) ) + memcpy(&interface.sin_addr, hp->h_addr, sizeof(interface.sin_addr)); + else + ast_log(LOG_WARNING, "Invalid address: %s\n", s); + } if ((s = ast_variable_retrieve(cfg, "general", "rtpstart"))) { rtpstart = atoi(s); if (rtpstart < 1024) @@ -1449,15 +1468,29 @@ ast_destroy(cfg); } if (rtpstart >= rtpend) { - ast_log(LOG_WARNING, "Unreasonable values for RTP start/end\n"); - rtpstart = 5000; + ast_log(LOG_WARNING, "Unreasonable values for RTP port range, using defaults\n"); + rtpstart = 8000; rtpend = 31000; } - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "RTP Allocating from port range %d -> %d\n", rtpstart, rtpend); + if (option_verbose) + ast_verbose("RTP using interface %s, port range %d - %d\n", inet_ntoa(interface.sin_addr), rtpstart, rtpend); } void ast_rtp_init(void)