From 08c71627839a9134367db354c8255f7a720e1ff3 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Sat, 6 Dec 2008 18:46:00 +0000 Subject: 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 --- ot_udp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ot_udp.c') diff --git a/ot_udp.c b/ot_udp.c index 764281c..8f55963 100644 --- a/ot_udp.c +++ b/ot_udp.c @@ -27,7 +27,7 @@ static void udp_make_connectionid( uint32_t * connid, const char * remoteip ) { (void)remoteip; /* Use a static secret for now */ - memcpy( connid, g_static_connid, 8 ); + memmove( connid, g_static_connid, 8 ); } static int udp_test_connectionid( const uint32_t * const connid, const char * remoteip ) { @@ -94,21 +94,21 @@ void handle_udp4( int64 serversocket ) { OT_SETIP( &peer, remoteip ); OT_SETPORT( &peer, &port ); - OT_FLAG( &peer ) = 0; + OT_PEERFLAG( &peer ) = 0; switch( event ) { - case 1: OT_FLAG( &peer ) |= PEER_FLAG_COMPLETED; break; - case 3: OT_FLAG( &peer ) |= PEER_FLAG_STOPPED; break; + case 1: OT_PEERFLAG( &peer ) |= PEER_FLAG_COMPLETED; break; + case 3: OT_PEERFLAG( &peer ) |= PEER_FLAG_STOPPED; break; default: break; } if( !left ) - OT_FLAG( &peer ) |= PEER_FLAG_SEEDING; + OT_PEERFLAG( &peer ) |= PEER_FLAG_SEEDING; outpacket[0] = htonl( 1 ); /* announce action */ outpacket[1] = inpacket[12/4]; - if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) /* Peer is gone. */ + if( OT_PEERFLAG( &peer ) & PEER_FLAG_STOPPED ) /* Peer is gone. */ r = remove_peer_from_torrent( hash, &peer, static_outbuf, FLAG_UDP ); else { torrent = add_peer_to_torrent( hash, &peer WANT_SYNC_PARAM( 0 ) ); -- cgit v1.2.3