static void natPulse( tr_shared * s, bool do_check ) { const tr_port private_peer_port = s->session->private_peer_port; const int is_enabled = s->isEnabled && !s->isShuttingDown; tr_port public_peer_port; int oldStatus; int newStatus; if( s->natpmp == NULL ) s->natpmp = tr_natpmpInit( ); if( s->upnp == NULL ) s->upnp = tr_upnpInit( ); oldStatus = tr_sharedTraversalStatus( s ); s->natpmpStatus = tr_natpmpPulse( s->natpmp, private_peer_port, is_enabled, &public_peer_port ); if( s->natpmpStatus == TR_PORT_MAPPED ) s->session->public_peer_port = public_peer_port; s->upnpStatus = tr_upnpPulse( s->upnp, private_peer_port, is_enabled, do_check ); newStatus = tr_sharedTraversalStatus( s ); if( newStatus != oldStatus ) tr_ninf( getKey( ), _( "State changed from \"%1$s\" to \"%2$s\"" ), getNatStateStr( oldStatus ), getNatStateStr( newStatus ) ); }
static void natPulse( tr_shared * s, tr_bool doPortCheck ) { const tr_port port = s->session->peerPort; const int isEnabled = s->isEnabled && !s->isShuttingDown; int oldStatus; int newStatus; if( s->natpmp == NULL ) s->natpmp = tr_natpmpInit( ); if( s->upnp == NULL ) s->upnp = tr_upnpInit( ); oldStatus = tr_sharedTraversalStatus( s ); s->natpmpStatus = tr_natpmpPulse( s->natpmp, port, isEnabled ); s->upnpStatus = tr_upnpPulse( s->upnp, port, isEnabled, doPortCheck ); newStatus = tr_sharedTraversalStatus( s ); if( newStatus != oldStatus ) tr_ninf( getKey( ), _( "State changed from \"%1$s\" to \"%2$s\"" ), getNatStateStr( oldStatus ), getNatStateStr( newStatus ) ); }