summaryrefslogtreecommitdiff
path: root/ot_udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_udp.c')
-rw-r--r--ot_udp.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/ot_udp.c b/ot_udp.c
index 8f55963..fb171e7 100644
--- a/ot_udp.c
+++ b/ot_udp.c
@@ -41,7 +41,6 @@ static int udp_test_connectionid( const uint32_t * const connid, const char * re
41/* UDP implementation according to http://xbtt.sourceforge.net/udp_tracker_protocol.html */ 41/* UDP implementation according to http://xbtt.sourceforge.net/udp_tracker_protocol.html */
42void handle_udp4( int64 serversocket ) { 42void handle_udp4( int64 serversocket ) {
43 ot_peer peer; 43 ot_peer peer;
44 ot_torrent *torrent;
45 ot_hash *hash = NULL; 44 ot_hash *hash = NULL;
46 char remoteip[4]; 45 char remoteip[4];
47 uint32_t *inpacket = (uint32_t*)static_inbuf; 46 uint32_t *inpacket = (uint32_t*)static_inbuf;
@@ -79,7 +78,7 @@ void handle_udp4( int64 serversocket ) {
79 if( r < 98 ) 78 if( r < 98 )
80 return; 79 return;
81 80
82 if( !udp_test_connectionid( inpacket, remoteip )) 81 if( !udp_test_connectionid( inpacket, remoteip ))
83 fprintf( stderr, "UDP connect Connection id missmatch.\n" ); 82 fprintf( stderr, "UDP connect Connection id missmatch.\n" );
84 83
85 /* We do only want to know, if it is zero */ 84 /* We do only want to know, if it is zero */
@@ -110,20 +109,15 @@ void handle_udp4( int64 serversocket ) {
110 109
111 if( OT_PEERFLAG( &peer ) & PEER_FLAG_STOPPED ) /* Peer is gone. */ 110 if( OT_PEERFLAG( &peer ) & PEER_FLAG_STOPPED ) /* Peer is gone. */
112 r = remove_peer_from_torrent( hash, &peer, static_outbuf, FLAG_UDP ); 111 r = remove_peer_from_torrent( hash, &peer, static_outbuf, FLAG_UDP );
113 else { 112 else
114 torrent = add_peer_to_torrent( hash, &peer WANT_SYNC_PARAM( 0 ) ); 113 r = 8 + add_peer_to_torrent_and_return_peers( hash, &peer, FLAG_UDP, numwant, static_outbuf + 8 );
115 if( !torrent )
116 return; /* XXX maybe send error */
117
118 r = 8 + return_peers_for_torrent( torrent, numwant, static_outbuf + 8, FLAG_UDP );
119 }
120 114
121 socket_send4( serversocket, static_outbuf, r, remoteip, remoteport ); 115 socket_send4( serversocket, static_outbuf, r, remoteip, remoteport );
122 stats_issue_event( EVENT_ANNOUNCE, FLAG_UDP, r ); 116 stats_issue_event( EVENT_ANNOUNCE, FLAG_UDP, r );
123 break; 117 break;
124 118
125 case 2: /* This is a scrape action */ 119 case 2: /* This is a scrape action */
126 if( !udp_test_connectionid( inpacket, remoteip )) 120 if( !udp_test_connectionid( inpacket, remoteip ))
127 fprintf( stderr, "UDP scrape Connection id missmatch.\n" ); 121 fprintf( stderr, "UDP scrape Connection id missmatch.\n" );
128 122
129 outpacket[0] = htonl( 2 ); /* scrape action */ 123 outpacket[0] = htonl( 2 ); /* scrape action */
@@ -138,4 +132,8 @@ void handle_udp4( int64 serversocket ) {
138 } 132 }
139} 133}
140 134
135void udp_init( ) {
136
137}
138
141const char *g_version_udp_c = "$Source$: $Revision$\n"; 139const char *g_version_udp_c = "$Source$: $Revision$\n";