This file is indexed.

/usr/include/libktorrent/utp/connection.h is in libktorrent-dev 1.3.1-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/***************************************************************************
 *   Copyright (C) 2009 by Joris Guisson                                   *
 *   joris.guisson@gmail.com                                               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
 ***************************************************************************/

#ifndef UTP_CONNECTION_H
#define UTP_CONNECTION_H

#include <QPair>
#include <QMutex>
#include <QWaitCondition>
#include <QBasicTimer>
#include <QSharedPointer>
#include <ktorrent_export.h>
#include <net/address.h>
#include <utp/utpprotocol.h>
#include <util/circularbuffer.h>
#include <util/timer.h>
#include <utp/remotewindow.h>
#include <boost/concept_check.hpp>




namespace utp
{
	class DelayWindow;
	class LocalWindow;
	class Transmitter;

	/**
		Keeps track of a single UTP connection
	*/
	class KTORRENT_EXPORT Connection : public QObject, public Retransmitter
	{
		Q_OBJECT
	public:
		enum Type
		{
			INCOMING,
			OUTGOING
		};

		/// Thrown when a transmission error occurs, server should kill the connection if it happens
		class TransmissionError
		{
		public:
			TransmissionError(const char* file, int line);

			QString location;
		};

		struct Stats
		{
			Type type;
			net::Address remote;
			ConnectionState state;
			bt::Uint16 send_connection_id;
			bt::Uint32 reply_micro;
			bt::Uint16 recv_connection_id;
			bt::Uint16 seq_nr;
			int eof_seq_nr;
			bt::Uint32 timeout;
			TimeValue absolute_timeout;
			int rtt;
			int rtt_var;
			bt::Uint32 packet_size;
			bt::Uint32 last_window_size_transmitted;

			bt::Uint64 bytes_received;
			bt::Uint64 bytes_sent;
			bt::Uint32 packets_received;
			bt::Uint32 packets_sent;
			bt::Uint64 bytes_lost;
			bt::Uint32 packets_lost;

			bool readable;
			bool writeable;
		};

		Connection(bt::Uint16 recv_connection_id, Type type, const net::Address & remote, Transmitter* transmitter);
		virtual ~Connection();

		/// Turn on or off blocking mode
		void setBlocking(bool on) {blocking = on;}

		/// Dump connection stats
		void dumpStats();

		/// Start connecting (OUTGOING only)
		void startConnecting();

		/// Get the connection stats
		const Stats & connectionStats() const {return stats;}

		/// Handle a single packet
		ConnectionState handlePacket(const PacketParser & parser, bt::Buffer::Ptr packet);

		/// Get the remote address
		const net::Address & remoteAddress() const {return stats.remote;}

		/// Get the receive connection id
		bt::Uint16 receiveConnectionID() const {return stats.recv_connection_id;}

		/// Send some data, returns the amount of bytes sent (or -1 on error)
		int send(const bt::Uint8* data, bt::Uint32 len);

		/// Read available data from local window, returns the amount of bytes read
		int recv(bt::Uint8* buf, bt::Uint32 max_len);

		/// Get the connection state
		ConnectionState connectionState() const {return stats.state;}

		/// Get the type of connection
		Type connectionType() const {return stats.type;}

		/// Get the number of bytes available
		bt::Uint32 bytesAvailable() const;

		/// Can we write to this socket
		bool isWriteable() const;

		/// Wait until the connectTo call fails or succeeds
		bool waitUntilConnected();

		/// Wait until there is data ready or the socket is closed or a timeout occurs
		bool waitForData(bt::Uint32 timeout = 0);

		/// Close the socket
		void close();

		/// Reset the connection
		void reset();

		/// Update the RTT time
		virtual void updateRTT(const Header* hdr, bt::Uint32 packet_rtt, bt::Uint32 packet_size);

		/// Retransmit a packet
		virtual void retransmit(PacketBuffer & packet, bt::Uint16 p_seq_nr);

		/// Is all data sent
		bool allDataSent() const;

		/// Get the current timeout
		virtual bt::Uint32 currentTimeout() const {return stats.timeout;}

		typedef QSharedPointer<Connection> Ptr;
		typedef QWeakPointer<Connection> WPtr;

		/// Set a weak pointer to self
		void setWeakPointer(WPtr ptr) {self = ptr;}

		/// Check if we haven't hit a timeout yet
		void checkTimeout(const TimeValue & now);

	private:
		void sendSYN();
		void sendState();
		void sendFIN();
		void sendReset();
		void updateDelayMeasurement(const Header* hdr);
		void sendStateOrData();
		void sendPackets();
		void sendPacket(bt::Uint32 type, bt::Uint16 p_ack_nr);
		void checkIfClosed();
		void sendDataPacket(PacketBuffer & packet, bt::Uint16 seq_nr, const TimeValue & now);
		void startTimer();
		void checkState();
		bt::Uint32 extensionLength() const;
		void handleTimeout();

	private:
		Transmitter* transmitter;
		LocalWindow* local_wnd;
		RemoteWindow* remote_wnd;
		bt::CircularBuffer output_buffer;
		//bt::Timer timer;
		mutable QMutex mutex;
		QWaitCondition connected;
		QWaitCondition data_ready;
		Stats stats;
		bool fin_sent;
		TimeValue last_packet_sent;
		DelayWindow* delay_window;
		Connection::WPtr self;
		bool blocking;

		friend class UTPServer;
	};

	/**
		Interface class for transmitting packets and notifying if a connection becomes readable or writeable
	 */
	class KTORRENT_EXPORT Transmitter
	{
	public:
		virtual ~Transmitter();

		/// Send a packet of a connection
		virtual bool sendTo(Connection::Ptr conn, const PacketBuffer & packet) = 0;

		/// Connection has become readable, writeable or both
		virtual void stateChanged(Connection::Ptr conn, bool readable, bool writeable) = 0;

		/// Called when the connection is closed
		virtual void closed(Connection::Ptr conn) = 0;
	};

}

#endif // UTP_CONNECTION_H