diff options
author | erdgeist <> | 2008-02-05 01:55:06 +0000 |
---|---|---|
committer | erdgeist <> | 2008-02-05 01:55:06 +0000 |
commit | cadf1803e1b36866a9f8a0e57d3b741360928928 (patch) | |
tree | d6ade7eba9f2886a59c1765880e20e0cf3d03f67 | |
parent | 90184649d021120c1b181bc6a6fe602802a17ef4 (diff) |
Fix endianess issues, also obey number of peers requested in udp announces
-rw-r--r-- | ot_udp.c | 4 | ||||
-rw-r--r-- | trackerlogic.c | 4 |
2 files changed, 5 insertions, 3 deletions
@@ -84,10 +84,12 @@ void handle_udp4( int64 serversocket ) { | |||
84 | /* if( !udp_test_connectionid( inpacket, remoteip )) | 84 | /* if( !udp_test_connectionid( inpacket, remoteip )) |
85 | fprintf( stderr, "UDP Connection id missmatch.\n" ); */ | 85 | fprintf( stderr, "UDP Connection id missmatch.\n" ); */ |
86 | 86 | ||
87 | numwant = 200; | ||
88 | /* We do only want to know, if it is zero */ | 87 | /* We do only want to know, if it is zero */ |
89 | left = inpacket[64/4] | inpacket[68/4]; | 88 | left = inpacket[64/4] | inpacket[68/4]; |
90 | 89 | ||
90 | numwant = ntohl( inpacket[92/4] ); | ||
91 | if (numwant > 200) numwant = 200; | ||
92 | |||
91 | event = ntohl( inpacket[80/4] ); | 93 | event = ntohl( inpacket[80/4] ); |
92 | port = *(uint16_t*)( static_inbuf + 96 ); | 94 | port = *(uint16_t*)( static_inbuf + 96 ); |
93 | hash = (ot_hash*)( static_inbuf + 16 ); | 95 | hash = (ot_hash*)( static_inbuf + 16 ); |
diff --git a/trackerlogic.c b/trackerlogic.c index f4bdf0b..fd6a6ee 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -304,8 +304,8 @@ exit_loop: | |||
304 | 304 | ||
305 | /* else { Handle UDP reply */ | 305 | /* else { Handle UDP reply */ |
306 | ((uint32_t*)reply)[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); | 306 | ((uint32_t*)reply)[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); |
307 | ((uint32_t*)reply)[3] = peer_list->peer_count - peer_list->seed_count; | 307 | ((uint32_t*)reply)[3] = htonl( peer_list->peer_count - peer_list->seed_count ); |
308 | ((uint32_t*)reply)[4] = peer_list->seed_count; | 308 | ((uint32_t*)reply)[4] = htonl( peer_list->seed_count); |
309 | 309 | ||
310 | mutex_bucket_unlock_by_hash( hash ); | 310 | mutex_bucket_unlock_by_hash( hash ); |
311 | return (size_t)20; | 311 | return (size_t)20; |