| 274 | | |
|---|
| 275 | | static tr_fd_t *fd = NULL; |
|---|
| 276 | | if( ! fd ) fd = tr_fdInit(); |
|---|
| 277 | | if( fd ) { |
|---|
| 278 | | _upnp = tr_upnpInit( fd ); |
|---|
| 279 | | tr_upnpStart( _upnp ); |
|---|
| 280 | | tr_upnpForwardPort( _upnp, port ); |
|---|
| 281 | | |
|---|
| 282 | | _natpmp = tr_natpmpInit( fd ); |
|---|
| 283 | | tr_natpmpStart( _natpmp ); |
|---|
| 284 | | tr_natpmpForwardPort( _natpmp, port ); |
|---|
| 285 | | |
|---|
| 286 | | NSDate *mappingStart = [NSDate date]; |
|---|
| 287 | | int status = 0; |
|---|
| 288 | | |
|---|
| 289 | | do { |
|---|
| 290 | | tr_upnpPulse( _upnp ); |
|---|
| 291 | | tr_natpmpPulse( _natpmp ); |
|---|
| 292 | | status = natTraversalStatus( _upnp, _natpmp ); |
|---|
| 293 | | } while( ( status == 1 || status == 3 ) && ABS( [mappingStart timeIntervalSinceNow] ) < 5. ); |
|---|
| 294 | | } |
|---|
| | 274 | tr_fdInit(); |
|---|
| | 275 | |
|---|
| | 276 | _upnp = tr_upnpInit(); |
|---|
| | 277 | tr_upnpStart( _upnp ); |
|---|
| | 278 | tr_upnpForwardPort( _upnp, port ); |
|---|
| | 279 | |
|---|
| | 280 | _natpmp = tr_natpmpInit(); |
|---|
| | 281 | tr_natpmpStart( _natpmp ); |
|---|
| | 282 | tr_natpmpForwardPort( _natpmp, port ); |
|---|
| | 283 | |
|---|
| | 284 | NSDate *mappingStart = [NSDate date]; |
|---|
| | 285 | int status = 0; |
|---|
| | 286 | |
|---|
| | 287 | do { |
|---|
| | 288 | tr_upnpPulse( _upnp ); |
|---|
| | 289 | tr_natpmpPulse( _natpmp ); |
|---|
| | 290 | status = natTraversalStatus( _upnp, _natpmp ); |
|---|
| | 291 | } while( ( status == 1 || status == 3 ) && ABS( [mappingStart timeIntervalSinceNow] ) < 5. ); |
|---|