Fix endianess issues, also obey number of peers requested in udp announces

master
Dirk Engling 16 years ago
parent 432cf92e7c
commit 4ee5fe81c7

@ -84,10 +84,12 @@ void handle_udp4( int64 serversocket ) {
/* if( !udp_test_connectionid( inpacket, remoteip ))
fprintf( stderr, "UDP Connection id missmatch.\n" ); */
numwant = 200;
/* We do only want to know, if it is zero */
left = inpacket[64/4] | inpacket[68/4];
numwant = ntohl( inpacket[92/4] );
if (numwant > 200) numwant = 200;
event = ntohl( inpacket[80/4] );
port = *(uint16_t*)( static_inbuf + 96 );
hash = (ot_hash*)( static_inbuf + 16 );
@ -138,4 +140,4 @@ void handle_udp4( int64 serversocket ) {
}
}
const char *g_version_udp_c = "$Source: /home/cvsroot/opentracker/ot_udp.c,v $: $Revision: 1.11 $\n";
const char *g_version_udp_c = "$Source: /home/cvsroot/opentracker/ot_udp.c,v $: $Revision: 1.12 $\n";

@ -304,8 +304,8 @@ exit_loop:
/* else { Handle UDP reply */
((uint32_t*)reply)[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM );
((uint32_t*)reply)[3] = peer_list->peer_count - peer_list->seed_count;
((uint32_t*)reply)[4] = peer_list->seed_count;
((uint32_t*)reply)[3] = htonl( peer_list->peer_count - peer_list->seed_count );
((uint32_t*)reply)[4] = htonl( peer_list->seed_count);
mutex_bucket_unlock_by_hash( hash );
return (size_t)20;
@ -357,4 +357,4 @@ void trackerlogic_deinit( void ) {
mutex_deinit( );
}
const char *g_version_trackerlogic_c = "$Source: /home/cvsroot/opentracker/trackerlogic.c,v $: $Revision: 1.100 $\n";
const char *g_version_trackerlogic_c = "$Source: /home/cvsroot/opentracker/trackerlogic.c,v $: $Revision: 1.101 $\n";

Loading…
Cancel
Save