$OpenBSD$ --- net/net-ip.cpp.orig Tue Jul 19 14:08:49 2011 +++ net/net-ip.cpp Fri Aug 19 11:11:59 2011 @@ -232,6 +232,7 @@ int IPNetwork::command(int argc, const char*const* arg int IPNetwork::open(const char * host, int port, int ttl) { char *g_addr; + Tcl& tcl = Tcl::instance(); // Check for SSM src address: Src,Group if ((g_addr=(char*)strchr(host,(int)','))!=NULL) { char s_addr_ssm[MAXHOSTNAMELEN]; @@ -273,6 +274,18 @@ int IPNetwork::open(const char * host, int port, int t (IPAddress&)local_ = local.sin_addr; disconnect_sock(ssock_); + /* + * Check whether a local port to be used was specified on the commandline + * If so, make sure that when setting RTP port, it is even, and RTCP uneven + */ + if (tcl.attr("localport") != NULL) { + int localport; + localport = atoi(tcl.attr("localport")); + if (ntohs(port) % 2 == 0) + port = (localport % 2 == 0) ? htons(localport) : htons(localport-1); + else + port = (localport % 2 == 0) ? htons(localport+1) : htons(localport); + } rsock_ = openrsock(g_addr_, s_addr_ssm_, port, local_); if (rsock_ < 0) { rsock_ = ssock_;