$OpenBSD$ --- net/net-ipv6.cpp.orig Thu Aug 18 09:55:38 2011 +++ net/net-ipv6.cpp Thu Aug 18 09:58:00 2011 @@ -258,6 +258,7 @@ int IP6Network::command(int argc, const char*const* ar int IP6Network::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]; @@ -291,6 +292,17 @@ int IP6Network::open(const char * host, int port, int } (IP6Address&)local_ = local.sin6_addr; + /* + * 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 = 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) { (void)::close(ssock_);