#ifdef OSP_SUPPORT
p->osphandle = -1;
#endif
- p->rtp = ast_rtp_new(sched, io, 1, 0);
+ if (sin) {
+ memcpy(&p->sa, sin, sizeof(p->sa));
+ if (ast_sip_ouraddrfor(&p->sa.sin_addr,&p->ourip))
+ memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
+ } else {
+ memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
+ }
+ p->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, p->ourip);
if (videosupport)
- p->vrtp = ast_rtp_new(sched, io, 1, 0);
+ p->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, p->ourip);
p->branch = rand();
p->tag = rand();
ast_rtp_setnat(p->vrtp, (p->nat == SIP_NAT_ALWAYS));
}
- if (sin) {
- memcpy(&p->sa, sin, sizeof(p->sa));
- if (ast_sip_ouraddrfor(&p->sa.sin_addr,&p->ourip))
- memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
- } else {
- memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
- }
/* z9hG4bK is a magic cookie. See RFC 3261 section 8.1.1.7 */
if (p->nat != SIP_NAT_NEVER)
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode);
+struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode, struct in_addr in);
+
void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
void ast_rtp_get_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
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_with_bindaddr(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode, struct in_addr addr)
{
struct ast_rtp *rtp;
int x;
for (;;) {
/* Must be an even port number by RTP spec */
rtp->us.sin_port = htons(x);
+ rtp->us.sin_addr = addr;
if (rtp->rtcp)
rtp->rtcp->us.sin_port = htons(x + 1);
if (!(first = bind(rtp->s, (struct sockaddr *)&rtp->us, sizeof(rtp->us))) &&
return rtp;
}
+struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode)
+{
+ struct in_addr ia;
+ memset(&ia, 0, sizeof(ia));
+ return ast_rtp_new_with_bindaddr(sched, io, rtcpenable, callbackmode, ia);
+}
+
int ast_rtp_settos(struct ast_rtp *rtp, int tos)
{
int res;