Changeset 2428
- Timestamp:
- Jul 19, 2007, 10:49:44 AM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/internal.h
r2427 r2428 86 86 #endif 87 87 88 /* Convenient macros to perform uint32_t endian conversions with89 char pointers */90 #define TR_HTONL(a,p) tr_htonl((a), ( uint8_t * )(p))91 static inline uint32_t tr_ntohl( uint8_t * p )92 {93 uint32_t u;94 memcpy( &u, p, sizeof( uint32_t ) );95 return ntohl( u );96 }97 static inline void tr_htonl( uint32_t a, uint8_t * p )98 {99 uint32_t u;100 u = htonl( a );101 memcpy ( p, &u, sizeof( uint32_t ) );102 }103 104 88 /* Sometimes the system defines MAX/MIN, sometimes not. In the latter 105 89 case, define those here since we will use them */ -
trunk/libtransmission/peer.c
r2374 r2428 227 227 } 228 228 229 /* utilities for endian conversions with char pointers */ 230 231 static uint32_t tr_ntohl( const void * p ) 232 { 233 uint32_t u; 234 memcpy( &u, p, sizeof( uint32_t ) ); 235 return ntohl( u ); 236 } 237 static void tr_htonl( uint32_t a, void * p ) 238 { 239 const uint32_t u = htonl( a ); 240 memcpy ( p, &u, sizeof( uint32_t ) ); 241 } 242 229 243 #include "peerext.h" 230 244 #include "peeraz.h" -
trunk/libtransmission/peeraz.h
r2427 r2428 115 115 116 116 /* set length to zero for now, we won't know it until after bencoding */ 117 TR_HTONL( 0, buf );117 tr_htonl( 0, buf ); 118 118 /* set name length, name, and version */ 119 TR_HTONL( azmsgLen( idx ), buf + 4 );119 tr_htonl( azmsgLen( idx ), buf + 4 ); 120 120 memcpy( buf + 8, azmsgStr( idx ), azmsgLen( idx ) ); 121 121 buf[8 + azmsgLen( idx )] = AZ_EXT_VERSION; … … 188 188 tr_bencFree( &val ); 189 189 /* we know the length now, fill it in */ 190 TR_HTONL( len - 4, buf );190 tr_htonl( len - 4, buf ); 191 191 192 192 /* XXX is there a way to tell azureus that the public port has changed? */ -
trunk/libtransmission/peermessages.h
r2339 r2428 82 82 int index; 83 83 84 TR_HTONL( size - 4, buf );84 tr_htonl( size - 4, buf ); 85 85 buf += 4; 86 86 if( peer->azproto ) … … 88 88 index = azmsgIdIndex( id ); 89 89 assert( 0 <= index ); 90 TR_HTONL( azmsgLen( index ), buf );90 tr_htonl( azmsgLen( index ), buf ); 91 91 buf += 4; 92 92 memcpy( buf, azmsgStr( index ), azmsgLen( index ) ); … … 139 139 buf = fillHeader( peer, hdrlen, PEER_MSG_PIECE, peer->outBlock ); 140 140 141 TR_HTONL( r->index, buf );141 tr_htonl( r->index, buf ); 142 142 buf += 4; 143 TR_HTONL( r->begin, buf );143 tr_htonl( r->begin, buf ); 144 144 buf += 4; 145 145 … … 262 262 p = getMessagePointer( peer, 4, PEER_MSG_HAVE ); 263 263 264 TR_HTONL( piece, p );264 tr_htonl( piece, p ); 265 265 266 266 peer_dbg( "SEND have %d", piece ); … … 311 311 p = getMessagePointer( peer, 12, PEER_MSG_REQUEST ); 312 312 313 TR_HTONL( r->index, p );314 TR_HTONL( r->begin, p + 4 );315 TR_HTONL( r->length, p + 8 );313 tr_htonl( r->index, p ); 314 tr_htonl( r->begin, p + 4 ); 315 tr_htonl( r->length, p + 8 ); 316 316 317 317 tr_cpDownloaderAdd( tor->completion, block ); … … 332 332 p = getMessagePointer( peer, 12, PEER_MSG_CANCEL ); 333 333 334 TR_HTONL( index, p );335 TR_HTONL( begin, p + 4 );336 TR_HTONL( length, p + 8 );334 tr_htonl( index, p ); 335 tr_htonl( begin, p + 4 ); 336 tr_htonl( length, p + 8 ); 337 337 338 338 peer_dbg( "SEND cancel %d/%d (%d bytes)", index, begin, length );
Note: See TracChangeset
for help on using the changeset viewer.