Changeset 11680
- Timestamp:
- Jan 15, 2011, 5:06:11 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/upnp.c
r11599 r11680 142 142 char intPort[8]; 143 143 char intClient[16]; 144 int i;145 144 146 145 tr_snprintf( portStr, sizeof( portStr ), "%d", handle->port ); 147 i = UPNP_GetSpecificPortMappingEntry( handle->urls.controlURL,148 handle->data.first.servicetype, portStr,149 "TCP", intClient, intPort );150 if( i!= UPNPCOMMAND_SUCCESS )146 if( UPNP_GetSpecificPortMappingEntry( handle->urls.controlURL, handle->data.first.servicetype, 147 portStr, "TCP", intClient, intPort ) != UPNPCOMMAND_SUCCESS || 148 UPNP_GetSpecificPortMappingEntry( handle->urls.controlURL, handle->data.first.servicetype, 149 portStr, "UDP", intClient, intPort ) != UPNPCOMMAND_SUCCESS ) 151 150 { 152 151 tr_ninf( getKey( ), _( "Port %d isn't forwarded" ), handle->port ); … … 162 161 handle->data.first.servicetype, 163 162 portStr, "TCP", NULL ); 163 UPNP_DeletePortMapping( handle->urls.controlURL, 164 handle->data.first.servicetype, 165 portStr, "UDP", NULL ); 164 166 tr_ninf( getKey( ), 165 167 _( … … 179 181 if( handle->state == TR_UPNP_MAP ) 180 182 { 181 int err = -1; 183 int err_tcp = -1; 184 int err_udp = -1; 182 185 errno = 0; 183 186 … … 188 191 char portStr[16]; 189 192 char desc[64]; 193 const int prev_errno = errno; 190 194 tr_snprintf( portStr, sizeof( portStr ), "%d", port ); 191 195 tr_snprintf( desc, sizeof( desc ), "%s at %d", TR_NAME, port ); 192 err = UPNP_AddPortMapping( handle->urls.controlURL, 196 197 errno = 0; 198 err_tcp = UPNP_AddPortMapping( handle->urls.controlURL, 193 199 handle->data.first.servicetype, 194 200 portStr, portStr, handle->lanaddr, 195 201 desc, "TCP", NULL ); 196 handle->isMapped = !err; 202 if( err_tcp ) 203 tr_ndbg( getKey( ), "TCP Port forwarding failed with error %d (errno %d - %s)", 204 err_tcp, errno, tr_strerror( errno ) ); 205 206 errno = 0; 207 err_udp = UPNP_AddPortMapping( handle->urls.controlURL, 208 handle->data.first.servicetype, 209 portStr, portStr, handle->lanaddr, 210 desc, "UDP", NULL ); 211 if( err_udp ) 212 tr_ndbg( getKey( ), "UDP Port forwarding failed with error %d (errno %d - %s)", 213 err_udp, errno, tr_strerror( errno ) ); 214 215 errno = prev_errno; 216 handle->isMapped = !err_tcp | !err_udp; 197 217 } 198 218 tr_ninf( getKey( ), … … 208 228 else 209 229 { 210 tr_ndbg( 211 getKey( ), 212 "Port forwarding failed with error %d (errno %d - %s)", err, 213 errno, tr_strerror( errno ) ); 214 tr_ndbg( 215 getKey( ), 216 "If your router supports UPnP, please make sure UPnP is enabled!" ); 230 tr_ndbg( getKey( ), "If your router supports UPnP, please make sure UPnP is enabled!" ); 217 231 handle->port = -1; 218 232 handle->state = TR_UPNP_ERR;
Note: See TracChangeset
for help on using the changeset viewer.