Changeset 12394
- Timestamp:
- Apr 28, 2011, 2:51:07 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/tr-udp.c
r12382 r12394 201 201 (struct sockaddr*)&from, &fromlen); 202 202 203 /* Test for the different packet types based on frequency: 204 µTP will be the most common, then DHT, then UDP trackers. */ 205 if( rc > 0 ) 206 { 207 #ifdef WITH_UTP 208 if( ss->isUTPEnabled && tr_utpPacket( buf, rc, (struct sockaddr*)&from, fromlen, ss ) ) 209 { 210 tr_ndbg( "UDP", "Handled uTP packet" ); 211 } 212 else 213 #endif 214 if( ss->isDHTEnabled && ( *buf == 'd' ) ) /* DHT */ 215 { 216 buf[rc] = '\0'; /* required by the DHT code */ 217 tr_dhtCallback( buf, rc, (struct sockaddr*)&from, fromlen, sv ); 218 tr_ndbg( "UDP", "Handled DHT packet" ); 219 } 220 else if( tau_handle_message( ss, buf, rc ) ) 221 { 222 tr_ndbg( "UDP", "Handled UDP tracker packet" ); 223 } 224 else 225 { 226 tr_ndbg( "UDP", "Unexpected UDP packet" ); 203 /* Since most packets we receive here are õTP, make quick inline 204 checks for the other protocols. The logic is as follows: 205 - all DHT packets start with 'd'; 206 - all UDP tracker packets start with a 32-bit (!) "action", which 207 is between 0 and 3; 208 - the above cannot be õTP packets, since these start with a 4-bit 209 version number (1). */ 210 if(rc > 0) { 211 if( buf[0] == 'd' ) { 212 buf[rc] = '\0'; /* required by the DHT code */ 213 tr_dhtCallback(buf, rc, (struct sockaddr*)&from, fromlen, sv); 214 } else if( rc >= 8 && 215 buf[0] == 0 && buf[1] == 0 && buf[2] == 0 && buf[3] <= 3 ) { 216 rc = tau_handle_message( ss, buf, rc ); 217 if( !rc ) 218 tr_ndbg("UDP", "Couldn't parse UDP tracker packet."); 219 } else { 220 rc = tr_utpPacket(buf, rc, (struct sockaddr*)&from, fromlen, ss); 221 if( !rc ) 222 tr_ndbg("UDP", "Unexpected UDP packet"); 227 223 } 228 224 }
Note: See TracChangeset
for help on using the changeset viewer.