Changeset 7579 for trunk/libtransmission/peer-io.c
- Timestamp:
- Jan 2, 2009, 5:46:22 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-io.c
r7576 r7579 79 79 }; 80 80 81 struct tr_peerIo82 {83 tr_bool isEncrypted;84 tr_bool isIncoming;85 tr_bool peerIdIsSet;86 tr_bool extendedProtocolSupported;87 tr_bool fastExtensionSupported;88 89 int magicNumber;90 91 uint8_t encryptionMode;92 tr_port port;93 int socket;94 95 uint8_t peerId[SHA_DIGEST_LENGTH];96 time_t timeCreated;97 98 tr_session * session;99 100 tr_address addr;101 102 tr_can_read_cb canRead;103 tr_did_write_cb didWrite;104 tr_net_error_cb gotError;105 void * userData;106 107 tr_bandwidth * bandwidth;108 tr_crypto * crypto;109 110 struct evbuffer * inbuf;111 struct evbuffer * outbuf;112 struct __tr_list outbuf_datatypes; /* struct tr_datatype */113 114 struct event event_read;115 struct event event_write;116 };117 118 81 /*** 119 82 **** … … 800 763 } 801 764 802 void803 tr_peerIoWriteUint8( tr_peerIo * io,804 struct evbuffer * outbuf,805 uint8_t writeme )806 {807 tr_peerIoWriteBytes( io, outbuf, &writeme, sizeof( uint8_t ) );808 }809 810 void811 tr_peerIoWriteUint16( tr_peerIo * io,812 struct evbuffer * outbuf,813 uint16_t writeme )814 {815 uint16_t tmp = htons( writeme );816 817 tr_peerIoWriteBytes( io, outbuf, &tmp, sizeof( uint16_t ) );818 }819 820 void821 tr_peerIoWriteUint32( tr_peerIo * io,822 struct evbuffer * outbuf,823 uint32_t writeme )824 {825 uint32_t tmp = htonl( writeme );826 827 tr_peerIoWriteBytes( io, outbuf, &tmp, sizeof( uint32_t ) );828 }829 830 765 /*** 831 766 **** … … 858 793 859 794 void 860 tr_peerIoReadUint8( tr_peerIo * io,861 struct evbuffer * inbuf,862 uint8_t * setme )863 {864 tr_peerIoReadBytes( io, inbuf, setme, sizeof( uint8_t ) );865 }866 867 void868 tr_peerIoReadUint16( tr_peerIo * io,869 struct evbuffer * inbuf,870 uint16_t * setme )871 {872 uint16_t tmp;873 tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint16_t ) );874 *setme = ntohs( tmp );875 }876 877 void878 tr_peerIoReadUint32( tr_peerIo * io,879 struct evbuffer * inbuf,880 uint32_t * setme )881 {882 uint32_t tmp;883 tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint32_t ) );884 *setme = ntohl( tmp );885 }886 887 void888 795 tr_peerIoDrain( tr_peerIo * io, 889 796 struct evbuffer * inbuf, … … 898 805 byteCount -= thisPass; 899 806 } 900 }901 902 int903 tr_peerIoGetAge( const tr_peerIo * io )904 {905 return time( NULL ) - io->timeCreated;906 807 } 907 808 … … 982 883 } 983 884 984 struct evbuffer *985 tr_peerIoGetReadBuffer( tr_peerIo * io )986 {987 assert( tr_isPeerIo( io ) );988 989 return io->inbuf;990 }991 992 tr_bool993 tr_peerIoHasBandwidthLeft( const tr_peerIo * io, tr_direction dir )994 {995 assert( tr_isPeerIo( io ) );996 997 return tr_bandwidthClamp( io->bandwidth, dir, 1024 ) > 0;998 }999 1000 885 /*** 1001 886 **** … … 1044 929 event_disable( io, event ); 1045 930 } 931 932 tr_bool 933 tr_peerIoHasBandwidthLeft( const tr_peerIo * io, 934 tr_direction dir ) 935 { 936 assert( tr_isPeerIo( io ) ); 937 938 return tr_bandwidthClamp( io->bandwidth, dir, 1024 ) > 0; 939 } 940
Note: See TracChangeset
for help on using the changeset viewer.