diff -ru asterisk-0.7.2/channels/chan_h323.c asterisk-0.7.2-bindip/channels/chan_h323.c --- asterisk-0.7.2/channels/chan_h323.c Tue Jan 13 09:24:26 2004 +++ asterisk-0.7.2-bindip/channels/chan_h323.c Fri Feb 20 15:24:14 2004 @@ -720,7 +720,7 @@ /* Keep track of stuff */ memset(p, 0, sizeof(struct oh323_pvt)); - p->rtp = ast_rtp_new(sched, io, 1, 0); + p->rtp = ast_rtp_new(sched, io, 1, 0, &bindaddr->sin_addr); if (!p->rtp) { ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", strerror(errno)); diff -ru asterisk-0.7.2/channels/chan_mgcp.c asterisk-0.7.2-bindip/channels/chan_mgcp.c --- asterisk-0.7.2/channels/chan_mgcp.c Mon Feb 2 06:38:08 2004 +++ asterisk-0.7.2-bindip/channels/chan_mgcp.c Fri Feb 20 15:29:28 2004 @@ -1735,7 +1735,7 @@ { ast_mutex_lock(&sub->lock); /* Allocate the RTP now */ - sub->rtp = ast_rtp_new(sched, io, 1, 0); + sub->rtp = ast_rtp_new(sched, io, 1, 0, &bindaddr.sin_addr); if (sub->rtp && sub->owner) sub->owner->fds[0] = ast_rtp_fd(sub->rtp); if (sub->rtp) diff -ru asterisk-0.7.2/channels/chan_sip.c asterisk-0.7.2-bindip/channels/chan_sip.c --- asterisk-0.7.2/channels/chan_sip.c Mon Feb 2 23:51:25 2004 +++ asterisk-0.7.2-bindip/channels/chan_sip.c Fri Feb 20 15:28:40 2004 @@ -1696,9 +1696,9 @@ p->initid = -1; p->autokillid = -1; p->stateid = -1; - p->rtp = ast_rtp_new(sched, io, 1, 0); + p->rtp = ast_rtp_new(sched, io, 1, 0, &bindaddr.sin_addr); if (videosupport) - p->vrtp = ast_rtp_new(sched, io, 1, 0); + p->vrtp = ast_rtp_new(sched, io, 1, 0, &bindaddr.sin_addr); p->branch = rand(); p->tag = rand(); diff -ru asterisk-0.7.2/channels/chan_skinny.c asterisk-0.7.2-bindip/channels/chan_skinny.c --- asterisk-0.7.2/channels/chan_skinny.c Mon Feb 2 06:38:08 2004 +++ asterisk-0.7.2-bindip/channels/chan_skinny.c Fri Feb 20 15:29:46 2004 @@ -1225,7 +1225,7 @@ { ast_mutex_lock(&sub->lock); /* Allocate the RTP */ - sub->rtp = ast_rtp_new(sched, io, 1, 0); + sub->rtp = ast_rtp_new(sched, io, 1, 0, &bindaddr.sin_addr); if (sub->rtp && sub->owner) sub->owner->fds[0] = ast_rtp_fd(sub->rtp); if (sub->rtp) diff -ru asterisk-0.7.2/include/asterisk/rtp.h asterisk-0.7.2-bindip/include/asterisk/rtp.h --- asterisk-0.7.2/include/asterisk/rtp.h Sat Nov 15 00:52:49 2003 +++ asterisk-0.7.2-bindip/include/asterisk/rtp.h Fri Feb 20 15:20:53 2004 @@ -48,7 +48,7 @@ typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *data); -struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode); +struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode, struct in_addr *local_addr); void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them); diff -ru asterisk-0.7.2/rtp.c asterisk-0.7.2-bindip/rtp.c --- asterisk-0.7.2/rtp.c Tue Nov 25 21:15:28 2003 +++ asterisk-0.7.2-bindip/rtp.c Fri Feb 20 15:24:51 2004 @@ -689,7 +689,8 @@ return rtcp; } -struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode) +struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, + int rtcpenable, int callbackmode, struct in_addr *local_addr) { struct ast_rtp *rtp; int x; @@ -715,6 +716,11 @@ } flags = fcntl(rtp->s, F_GETFL); fcntl(rtp->s, F_SETFL, flags | O_NONBLOCK); + + /* use the requested local IP address, if any */ + if (local_addr) + memcpy(&rtp->us.sin_addr, local_addr, sizeof(rtp->us.sin_addr)); + /* Find us a place */ x = (rand() % (rtpend-rtpstart)) + rtpstart; x = x & ~1;