If i remember correctly SIP RFC reccomends this behaviour,
Anyway, it think that in advanced config options we can set a SIP port nr
Thanks
Vadim
Darshaka Pathirana wrote:
> Hi!
>
> Is there any reason why QuteCom alwayas tries to allocate src-port 5060
> when registering on a remote server?
>
> The code in subject is this (in
> wengophone/src/model/network/NetworkDiscovery.cpp):
>
> unsigned NetworkDiscovery::getFreeLocalPort() {
> Config & config = ConfigManager::getInstance().getCurrentConfig();
> int localPort = SIP_PORT;
>
> if (!is_local_udp_port_used(NULL, config.getNetworkSipLocalPort())) {
> LOG_DEBUG("UDP port configured, will use port number : "
> + String::fromNumber(config.getNetworkSipLocalPort()));
> return config.getNetworkSipLocalPort();
> }
> if (!is_local_udp_port_used(NULL, localPort)) {
> LOG_DEBUG("UDP port 5060 is free");
> return localPort;
> } else if (!is_local_udp_port_used(NULL, localPort + 1)) {
> LOG_DEBUG("UDP port 5060 is busy, will use 5061");
> return localPort + 1;
> } else {
> localPort = get_local_free_udp_port(NULL);
> if (localPort == -1) {
> LOG_DEBUG("cannot get a free local port");
> localPort = 0;
> }
> LOG_DEBUG("UDP port 5061 is busy, will use random port number :
> " + String::fromNumber(localPort));
> return localPort;
> }
> }
>
> [1] states that there is no reason for a client to always use the same
> src-port number - the contrary is the case: the client should get a
> "pseudo-random" port number for each process...
>
> [1]
> http://www.tcpipguide.com/free/t_TCPIPClientEphemeralPortsandClientServerApplicatio.htm
>
> QuteComs behaviour also causes a number of problems when running a
> SIP-Server (asterisk) on localhost (or - under special circumstances -
> even if in the same network).
>
> I found some posts[2][3] in the wengophone-devel-mailling list but
> they were primary workarounds.
>
> [1] http://article.gmane.org/gmane.comp.voip.wengophone.devel/594
> [2] http://article.gmane.org/gmane.comp.voip.wengophone.devel/947
>
> I tried a quick 'n dirty hack to get a random port number but it
> seems that it just works for Windows and breaks Mac and Linux.
> But I do not know why.
>
> # HG changeset patch
> # User Darshaka Pathirana <[EMAIL PROTECTED]>
> # Date 1214762709 -7200
> # Node ID 504e52162cdb92920f13fb26dec0da23cc71eaa8
> # Parent dce8e9215e87a504dc76b30dc6a8574861c8f560
> always use random local udp port (should be a config setting)
>
> --- a/wengophone/src/model/network/NetworkDiscovery.cpp Sun Jun 29
> 14:26:26 2008 +0200
> +++ b/wengophone/src/model/network/NetworkDiscovery.cpp Sun Jun 29
> 20:05:09 2008 +0200
> @@ -141,16 +141,17 @@ unsigned NetworkDiscovery::getFreeLocalP
> unsigned NetworkDiscovery::getFreeLocalPort() {
> Config & config = ConfigManager::getInstance().getCurrentConfig();
> int localPort = SIP_PORT;
> + bool randomPort = true;
>
> - if (!is_local_udp_port_used(NULL, config.getNetworkSipLocalPort())) {
> + if (!randomPort && !is_local_udp_port_used(NULL,
> config.getNetworkSipLocalPort())) {
> LOG_DEBUG("UDP port configured, will use port number : "
> + String::fromNumber(config.getNetworkSipLocalPort()));
> return config.getNetworkSipLocalPort();
> }
> - if (!is_local_udp_port_used(NULL, localPort)) {
> + if (!randomPort && !is_local_udp_port_used(NULL, localPort)) {
> LOG_DEBUG("UDP port 5060 is free");
> return localPort;
> - } else if (!is_local_udp_port_used(NULL, localPort + 1)) {
> + } else if (!randomPort && !is_local_udp_port_used(NULL, localPort + 1))
> {
> LOG_DEBUG("UDP port 5060 is busy, will use 5061");
> return localPort + 1;
> } else {
> @@ -159,7 +160,12 @@ unsigned NetworkDiscovery::getFreeLocalP
> LOG_DEBUG("cannot get a free local port");
> localPort = 0;
> }
> - LOG_DEBUG("UDP port 5061 is busy, will use random port number :
> " + String::fromNumber(localPort));
> + if (!randomPort) {
> + LOG_DEBUG("UDP port 5061 is busy, will use random port
> number : " + String::fromNumber(localPort));
> + } else {
> + LOG_DEBUG("UDP port set to random, will use random port
> number : " + String::fromNumber(localPort));
> + }
> +
> return localPort;
> }
> }
>
>
> Any ideas?
>
> Greetings,
> - Darsha
>
> _______________________________________________
> QuteCom-dev mailing list
> [email protected]
> http://lists.qutecom.org/mailman/listinfo/qutecom-dev
>
>
>
_______________________________________________
QuteCom-dev mailing list
[email protected]
http://lists.qutecom.org/mailman/listinfo/qutecom-dev