From 343e51abbec01a45a396f20eeff41eef794a35cc Mon Sep 17 00:00:00 2001 From: Josh Elsasser Date: Mon, 18 Dec 2006 03:45:22 +0000 Subject: [PATCH] Add peer's port to tr_peer_stat_t. --- libtransmission/peer.c | 12 +++++++++++- libtransmission/peer.h | 1 + libtransmission/transmission.c | 11 ++++++----- libtransmission/transmission.h | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/libtransmission/peer.c b/libtransmission/peer.c index d4fcdc676..d42ef9df7 100644 --- a/libtransmission/peer.c +++ b/libtransmission/peer.c @@ -537,7 +537,7 @@ int tr_peerIsDownloading( tr_peer_t * peer ) } /*********************************************************************** - * tr_peerIsDownloading + * tr_peerProgress *********************************************************************** * **********************************************************************/ @@ -546,6 +546,16 @@ float tr_peerProgress( tr_peer_t * peer ) return peer->progress; } +/*********************************************************************** + * tr_peerPort + *********************************************************************** + * Returns peer's listening port in host byte order + **********************************************************************/ +int tr_peerPort( tr_peer_t * peer ) +{ + return ntohs( peer->port ); +} + /*********************************************************************** * tr_peerBitfield *********************************************************************** diff --git a/libtransmission/peer.h b/libtransmission/peer.h index 382b19259..192572e66 100644 --- a/libtransmission/peer.h +++ b/libtransmission/peer.h @@ -44,6 +44,7 @@ int tr_peerIsIncoming ( tr_peer_t * ); int tr_peerIsUploading ( tr_peer_t * ); int tr_peerIsDownloading ( tr_peer_t * ); float tr_peerProgress ( tr_peer_t * ); +int tr_peerPort ( tr_peer_t * ); uint8_t * tr_peerBitfield ( tr_peer_t * ); float tr_peerDownloadRate ( tr_peer_t * ); int tr_peerIsUnchoked ( tr_peer_t * ); diff --git a/libtransmission/transmission.c b/libtransmission/transmission.c index e7079ed91..50ec6404e 100644 --- a/libtransmission/transmission.c +++ b/libtransmission/transmission.c @@ -584,11 +584,12 @@ tr_peer_stat_t * tr_torrentPeers( tr_torrent_t * tor, int * peerCount ) peers[i].client = tr_clientForId(tr_peerId(peer)); - peers[i].isConnected = tr_peerIsConnected(peer); - peers[i].isIncoming = tr_peerIsIncoming(peer); - peers[i].isDownloading = tr_peerIsDownloading(peer); - peers[i].isUploading = tr_peerIsUploading(peer); - peers[i].progress = tr_peerProgress(peer); + peers[i].isConnected = tr_peerIsConnected( peer ); + peers[i].isIncoming = tr_peerIsIncoming( peer ); + peers[i].isDownloading = tr_peerIsDownloading( peer ); + peers[i].isUploading = tr_peerIsUploading( peer ); + peers[i].progress = tr_peerProgress( peer ); + peers[i].port = tr_peerPort( peer ); } } diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 40dcaf3e1..27e06f80e 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -396,6 +396,7 @@ struct tr_peer_stat_s int isDownloading; int isUploading; float progress; + int port; }; struct tr_msg_list_s