Problem binding socket in nat_detect.c

HC
Howard Chalkley
Thu, Jan 5, 2017 4:36 PM

I am upgrading our code to use v2.5.5 of the PJSIP library: we use it to handle communication with TURN servers, in the game "Elite:Dangerous"

I found in unit testing after the upgrade that the call to detect the user's NAT type was no longer working. The call in nat_detect.c to pj_sock_bind() was failing, returning a status code 130047

I found that adding the following additional line, (near line 285) to preset the address family within the local_addr before the bind call, fixed the problem:

pj_bzero(&sess->local_addr, sizeof(pj_sockaddr));
addr_len = pj_sockaddr_get_len(server);
sess->local_addr.addr.sa_family = server->addr.sa_family; // added
status = pj_sock_bind(sess->sock, &sess->local_addr, addr_len);
if (status != PJ_SUCCESS)
   goto on_error;

I'm running a Windows 64 build, using Visual Studio 15, running on Windows 10 Pro

            Howard Chalkley
            Frontier Developments
            www.frontier.co.uk<http://www.frontier.co.uk>
I am upgrading our code to use v2.5.5 of the PJSIP library: we use it to handle communication with TURN servers, in the game "Elite:Dangerous" I found in unit testing after the upgrade that the call to detect the user's NAT type was no longer working. The call in nat_detect.c to pj_sock_bind() was failing, returning a status code 130047 I found that adding the following additional line, (near line 285) to preset the address family within the local_addr before the bind call, fixed the problem: pj_bzero(&sess->local_addr, sizeof(pj_sockaddr)); addr_len = pj_sockaddr_get_len(server); sess->local_addr.addr.sa_family = server->addr.sa_family; // added status = pj_sock_bind(sess->sock, &sess->local_addr, addr_len); if (status != PJ_SUCCESS) goto on_error; I'm running a Windows 64 build, using Visual Studio 15, running on Windows 10 Pro Howard Chalkley Frontier Developments www.frontier.co.uk<http://www.frontier.co.uk>
NI
Nanang Izzuddin
Thu, Jan 12, 2017 2:26 AM

Hi Howard,

Just fixed this in SVN trunk at https://trac.pjsip.org/repos/changeset/5523.

Thank you for the report.

BR,
nanang

On Thu, Jan 5, 2017 at 11:36 PM, Howard Chalkley hchalkley@frontier.co.uk
wrote:

I am upgrading our code to use v2.5.5 of the PJSIP library: we use it to
handle communication with TURN servers, in the game “Elite:Dangerous”

I found in unit testing after the upgrade that the call to detect the
user’s NAT type was no longer working. The call in nat_detect.c to
pj_sock_bind() was failing, returning a status code 130047

I found that adding the following additional line, (near line 285) to
preset the address family within the local_addr before the bind call, fixed
the problem:

 pj_bzero(&sess->local_addr, sizeof(pj_sockaddr));

 addr_len = pj_sockaddr_get_len(server);

 *sess**->**local_addr**.**addr**.**sa_family** = **server**->**addr*

*.sa_family; *// added

 status = pj_sock_bind(sess->sock, &sess->local_addr, addr_len);

 if (status != PJ_SUCCESS)

    goto on_error;

I’m running a Windows 64 build, using Visual Studio 15, running on Windows
10 Pro

             Howard Chalkley

             Frontier Developments

             www.frontier.co.uk

Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Hi Howard, Just fixed this in SVN trunk at https://trac.pjsip.org/repos/changeset/5523. Thank you for the report. BR, nanang On Thu, Jan 5, 2017 at 11:36 PM, Howard Chalkley <hchalkley@frontier.co.uk> wrote: > > > I am upgrading our code to use v2.5.5 of the PJSIP library: we use it to > handle communication with TURN servers, in the game “Elite:Dangerous” > > > > I found in unit testing after the upgrade that the call to detect the > user’s NAT type was no longer working. The call in nat_detect.c to > pj_sock_bind() was failing, returning a status code 130047 > > > > I found that adding the following additional line, (near line 285) to > preset the address family within the local_addr before the bind call, fixed > the problem: > > > > pj_bzero(&sess->local_addr, sizeof(pj_sockaddr)); > > addr_len = pj_sockaddr_get_len(server); > > *sess**->**local_addr**.**addr**.**sa_family** = **server**->**addr* > *.**sa_family**; **// added* > > status = pj_sock_bind(sess->sock, &sess->local_addr, addr_len); > > if (status != PJ_SUCCESS) > > goto on_error; > > > > I’m running a Windows 64 build, using Visual Studio 15, running on Windows > 10 Pro > > > > Howard Chalkley > > Frontier Developments > > www.frontier.co.uk > > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > >