--- chan_sip.c 2004-05-18 20:17:06.000000000 -0400 +++ chan_sip.c 2004-05-18 20:17:51.000000000 -0400 @@ -124,6 +124,9 @@ #define DEFAULT_SIP_PORT 5060 /* From RFC 2543 */ #define SIP_MAX_PACKET 1500 /* Also from RFC 2543, should sub headers tho */ +#define DEFAULT_RTP_PORTSTART 8000 +#define DEFAULT_RTP_PORTEND 31000 + #define ALLOWED_METHODS "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER" static char context[AST_MAX_EXTENSION] = "default"; @@ -476,6 +479,9 @@ static int globalcanreinvite = REINVITE_INVITE; +static int conf_rtp_portstart = DEFAULT_RTP_PORTSTART; +static int conf_rtp_portend = DEFAULT_RTP_PORTEND; +static struct sockaddr_in bindaddr_rtp; static struct sockaddr_in bindaddr; static struct sockaddr_in externip; static struct ast_ha *localaddr; @@ -2006,9 +2012,13 @@ p->initid = -1; p->autokillid = -1; p->stateid = -1; - p->rtp = ast_rtp_new(sched, io, 1, 0); + + memcpy(&bindaddr_rtp, &bindaddr, sizeof(struct sockaddr_in)); /* set our RTP bind address */ + ast_rtp_set_portrange(conf_rtp_portstart, conf_rtp_portend); /* set our RTP port range */ + bindaddr_rtp.sin_port = 0; /* and let RTP pick them */ + p->rtp = ast_rtp_create(sched, io, 1, 0, &bindaddr_rtp); /* create the ports */ if (videosupport) - p->vrtp = ast_rtp_new(sched, io, 1, 0); + p->vrtp = ast_rtp_create(sched, io, 1, 0, &bindaddr_rtp); p->branch = rand(); p->tag = rand(); @@ -7544,6 +7554,18 @@ } else { ast_log(LOG_WARNING, "Invalid port number '%s' at line %d of %s\n", v->value, v->lineno, config); } + } else if (!strcasecmp(v->name, "rtpports")) { + int res=sscanf(v->value, "%i,%i", &conf_rtp_portstart, &conf_rtp_portend); + if (res != 2 || conf_rtp_portstart<0 + || conf_rtp_portend<1 + || conf_rtp_portstart >65534 + || conf_rtp_portend >65535 + || conf_rtp_portstart > conf_rtp_portend ) { + ast_log(LOG_WARNING, "Invalid format for rtpport option '%s' at line %d of %s, using defaults\n", v->value, v->lineno, config); + conf_rtp_portstart=DEFAULT_RTP_PORTSTART; + conf_rtp_portend=DEFAULT_RTP_PORTEND; + } + ast_verbose("Channel %s is using RTP ports %d - %d\n", type, conf_rtp_portstart, conf_rtp_portend); #ifdef MYSQL_FRIENDS } else if (!strcasecmp(v->name, "dbuser")) { strncpy(mydbuser, v->value, sizeof(mydbuser) - 1);