diff options
author | erdgeist <> | 2008-12-06 18:46:00 +0000 |
---|---|---|
committer | erdgeist <> | 2008-12-06 18:46:00 +0000 |
commit | 08c71627839a9134367db354c8255f7a720e1ff3 (patch) | |
tree | b429abf6b3c26c7f851b522f5d4fb6797ad02d29 /ot_udp.c | |
parent | a4ed31d517f77a21afe12918a9cb256489daac74 (diff) |
Renamed OT_FLAG to OT_PEERFLAG to make code easier to read
Introduced READ16/32 and WRITE16/32 makros to abstract loading/storing from unaligned addresses away on cpu's that can actually load/store everywhere
Removed all unnecessary memmoves, especially where it only moved 6 bytes in inner loop. I replaced them with WRITE16/32(READ16/32()) makros
Diffstat (limited to 'ot_udp.c')
-rw-r--r-- | ot_udp.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -27,7 +27,7 @@ static void udp_make_connectionid( uint32_t * connid, const char * remoteip ) { | |||
27 | (void)remoteip; | 27 | (void)remoteip; |
28 | 28 | ||
29 | /* Use a static secret for now */ | 29 | /* Use a static secret for now */ |
30 | memcpy( connid, g_static_connid, 8 ); | 30 | memmove( connid, g_static_connid, 8 ); |
31 | } | 31 | } |
32 | 32 | ||
33 | static int udp_test_connectionid( const uint32_t * const connid, const char * remoteip ) { | 33 | static int udp_test_connectionid( const uint32_t * const connid, const char * remoteip ) { |
@@ -94,21 +94,21 @@ void handle_udp4( int64 serversocket ) { | |||
94 | 94 | ||
95 | OT_SETIP( &peer, remoteip ); | 95 | OT_SETIP( &peer, remoteip ); |
96 | OT_SETPORT( &peer, &port ); | 96 | OT_SETPORT( &peer, &port ); |
97 | OT_FLAG( &peer ) = 0; | 97 | OT_PEERFLAG( &peer ) = 0; |
98 | 98 | ||
99 | switch( event ) { | 99 | switch( event ) { |
100 | case 1: OT_FLAG( &peer ) |= PEER_FLAG_COMPLETED; break; | 100 | case 1: OT_PEERFLAG( &peer ) |= PEER_FLAG_COMPLETED; break; |
101 | case 3: OT_FLAG( &peer ) |= PEER_FLAG_STOPPED; break; | 101 | case 3: OT_PEERFLAG( &peer ) |= PEER_FLAG_STOPPED; break; |
102 | default: break; | 102 | default: break; |
103 | } | 103 | } |
104 | 104 | ||
105 | if( !left ) | 105 | if( !left ) |
106 | OT_FLAG( &peer ) |= PEER_FLAG_SEEDING; | 106 | OT_PEERFLAG( &peer ) |= PEER_FLAG_SEEDING; |
107 | 107 | ||
108 | outpacket[0] = htonl( 1 ); /* announce action */ | 108 | outpacket[0] = htonl( 1 ); /* announce action */ |
109 | outpacket[1] = inpacket[12/4]; | 109 | outpacket[1] = inpacket[12/4]; |
110 | 110 | ||
111 | if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) /* Peer is gone. */ | 111 | if( OT_PEERFLAG( &peer ) & PEER_FLAG_STOPPED ) /* Peer is gone. */ |
112 | r = remove_peer_from_torrent( hash, &peer, static_outbuf, FLAG_UDP ); | 112 | r = remove_peer_from_torrent( hash, &peer, static_outbuf, FLAG_UDP ); |
113 | else { | 113 | else { |
114 | torrent = add_peer_to_torrent( hash, &peer WANT_SYNC_PARAM( 0 ) ); | 114 | torrent = add_peer_to_torrent( hash, &peer WANT_SYNC_PARAM( 0 ) ); |