--- rtp.c 2004-07-07 22:10:34.000000000 +0200 +++ rtp.bak 2004-07-07 22:11:12.000000000 +0200 @@ -50,6 +50,7 @@ static int dtmftimeout = 3000; /* 3000 samples */ +static struct sockaddr_in bindaddr; static int rtpstart = 0; static int rtpend = 0; @@ -814,6 +815,9 @@ x = (rand() % (rtpend-rtpstart)) + rtpstart; x = x & ~1; startplace = x; + + memcpy(&rtp->us.sin_addr, &bindaddr.sin_addr, sizeof(rtp->us.sin_addr)); + for (;;) { /* Must be an even port number by RTP spec */ rtp->us.sin_port = htons(x); @@ -1479,7 +1483,12 @@ void ast_rtp_reload(void) { struct ast_config *cfg; + struct hostent *hp; + struct ast_hostent ahp; char *s; + + memset(&bindaddr, 0, sizeof(bindaddr)); + rtpstart = 5000; rtpend = 31000; cfg = ast_load("rtp.conf"); @@ -1498,6 +1507,15 @@ if (rtpend > 65535) rtpend = 65535; } + if ((s = ast_variable_retrieve(cfg,"general","bindaddr"))) { + if (!(hp = ast_gethostbyname(s, &ahp))) { + ast_log(LOG_WARNING, "Invalid address: %s\n", s); + } else { + memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr)); + if (option_verbose > 2) + ast_log(LOG_NOTICE, "Setting RTP address to %s\n", s); + } + } ast_destroy(cfg); } if (rtpstart >= rtpend) {