summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-12-24 07:10:43 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-12-24 07:10:43 +0000
commit708b9f4a3da70e963968c0a013dea6777c6b276e (patch)
tree576c79c5284f7971a1542ec1ac14d68d0f5f6dd7 /src
parent9c3e8fbd9c92cc858c2b0f805714e19ce97b7983 (diff)
* src/SuggestPieceMessage.h: Removed.
* src/PortMessage.h: Removed. * src/SuggestPieceMessage.h: Removed. * src/KeepAliveMessage.h: Removed. * src/HandshakeMessage.h: Removed. * src/PeerInteraction.h: Removed. * src/UnchokeMessage.h: Removed. * src/PieceMessage.h: Removed. * src/RequestMessage.h: Removed. * src/InterestedMessage.h: Removed. * src/HaveMessage.h: Removed. * src/CancelMessage.h: Removed. * src/RejectMessage.h: Removed. * src/AllowedFastMessage.h: Removed. * src/HaveNoneMessage.h: Removed. * src/SimplePeerMessage.h: Removed. * src/HaveAllMessage.h: Removed. * src/BitfieldMessage.h: Removed. * src/PeerMessageFactory.h: Removed. * src/NotInterestedMessage.h: Removed. * src/ChokeMessage.h: Removed. * src/PeerMessage.h: Removed.
Diffstat (limited to 'src')
-rw-r--r--src/AllowedFastMessage.cc91
-rw-r--r--src/AllowedFastMessage.h80
-rw-r--r--src/BitfieldMessage.cc96
-rw-r--r--src/BitfieldMessage.h105
-rw-r--r--src/BtHandshakeMessage.cc2
-rw-r--r--src/BtRequestMessage.cc1
-rw-r--r--src/BtSuggestPieceMessage.cc1
-rw-r--r--src/CancelMessage.cc93
-rw-r--r--src/CancelMessage.h92
-rw-r--r--src/ChokeMessage.cc86
-rw-r--r--src/ChokeMessage.h63
-rw-r--r--src/HandshakeMessage.cc100
-rw-r--r--src/HandshakeMessage.h71
-rw-r--r--src/HaveAllMessage.cc85
-rw-r--r--src/HaveAllMessage.h61
-rw-r--r--src/HaveMessage.cc87
-rw-r--r--src/HaveMessage.h80
-rw-r--r--src/HaveNoneMessage.cc84
-rw-r--r--src/HaveNoneMessage.h61
-rw-r--r--src/InterestedMessage.cc83
-rw-r--r--src/InterestedMessage.h63
-rw-r--r--src/KeepAliveMessage.cc51
-rw-r--r--src/KeepAliveMessage.h60
-rw-r--r--src/Makefile.am22
-rw-r--r--src/Makefile.in141
-rw-r--r--src/NotInterestedMessage.cc83
-rw-r--r--src/NotInterestedMessage.h63
-rw-r--r--src/PeerInteraction.cc453
-rw-r--r--src/PeerInteraction.h128
-rw-r--r--src/PeerMessage.cc48
-rw-r--r--src/PeerMessage.h108
-rw-r--r--src/PeerMessageFactory.cc281
-rw-r--r--src/PeerMessageFactory.h91
-rw-r--r--src/PeerMessageUtil.cc15
-rw-r--r--src/PeerMessageUtil.h4
-rw-r--r--src/PieceMessage.cc281
-rw-r--r--src/PieceMessage.h120
-rw-r--r--src/PortMessage.cc51
-rw-r--r--src/PortMessage.h67
-rw-r--r--src/RejectMessage.cc106
-rw-r--r--src/RejectMessage.h92
-rw-r--r--src/RequestMessage.cc116
-rw-r--r--src/RequestMessage.h99
-rw-r--r--src/SimplePeerMessage.cc64
-rw-r--r--src/SimplePeerMessage.h55
-rw-r--r--src/SuggestPieceMessage.cc83
-rw-r--r--src/SuggestPieceMessage.h75
-rw-r--r--src/UnchokeMessage.cc83
-rw-r--r--src/UnchokeMessage.h63
49 files changed, 25 insertions, 4363 deletions
diff --git a/src/AllowedFastMessage.cc b/src/AllowedFastMessage.cc
deleted file mode 100644
index 3cfda543..00000000
--- a/src/AllowedFastMessage.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "AllowedFastMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "Util.h"
-#include "DlAbortEx.h"
-
-AllowedFastMessage* AllowedFastMessage::create(const char* data, int dataLength) {
- if(dataLength != 5) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "allowed fast", dataLength, 5);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "allowed fast", ID);
- }
- AllowedFastMessage* allowedFastMessage = new AllowedFastMessage();
- allowedFastMessage->setIndex(PeerMessageUtil::getIntParam(data, 1));
- return allowedFastMessage;
-}
-
-void AllowedFastMessage::receivedAction() {
- if(!peer->isFastExtensionEnabled()) {
- throw new DlAbortEx("%s received while fast extension is disabled",
- toString().c_str());
- }
- peer->addFastSetIndex(index);
-}
-
-const char* AllowedFastMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 5, 4bytes
- * id --- 17, 1byte
- * piece index --- index, 4bytes
- * total: 9bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, ID);
- PeerMessageUtil::setIntParam(&msg[5], index);
- }
- return msg;
-}
-
-int AllowedFastMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void AllowedFastMessage::onSendComplete() {
- peerInteraction->addFastSetIndex(index);
-}
-
-void AllowedFastMessage::check() const {
- PeerMessageUtil::checkIndex(index, pieces);
-}
-
-string AllowedFastMessage::toString() const {
- return "allowed fast index="+Util::itos(index);
-}
diff --git a/src/AllowedFastMessage.h b/src/AllowedFastMessage.h
deleted file mode 100644
index 4bd99632..00000000
--- a/src/AllowedFastMessage.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_ALLOWED_FAST_MESSAGE_H_
-#define _D_ALLOWED_FAST_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class AllowedFastMessage : public SimplePeerMessage {
-private:
- int index;
- // for check
- int pieces;
- char msg[9];
-protected:
- virtual void onSendComplete();
-public:
- AllowedFastMessage(int index = 0)
- :SimplePeerMessage(),
- index(index),
- pieces(0) {}
-
- virtual ~AllowedFastMessage() {}
-
- enum ID_t {
- ID = 17
- };
-
- void setIndex(int index) {
- this->index = index;
- }
- int getIndex() const { return index; }
-
- void setPieces(int pieces) {
- this->pieces = pieces;
- }
- int getPieces() const { return pieces;}
-
- static AllowedFastMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual void check() const;
- virtual string toString() const;
-};
-
-#endif // _D_ALLOWED_FAST_MESSAGE_H_
diff --git a/src/BitfieldMessage.cc b/src/BitfieldMessage.cc
deleted file mode 100644
index 8bf6bfe7..00000000
--- a/src/BitfieldMessage.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "BitfieldMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "Util.h"
-#include "DlAbortEx.h"
-
-void BitfieldMessage::setBitfield(const unsigned char* bitfield, int bitfieldLength) {
- if(this->bitfield != NULL) {
- delete [] this->bitfield;
- }
- this->bitfieldLength = bitfieldLength;
- this->bitfield = new unsigned char[this->bitfieldLength];
- memcpy(this->bitfield, bitfield, this->bitfieldLength);
-}
-
-BitfieldMessage* BitfieldMessage::create(const char* data, int dataLength) {
- if(dataLength <= 1) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be greater than %d", "bitfield", dataLength, 1);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "bitfield", ID);
- }
- BitfieldMessage* bitfieldMessage = new BitfieldMessage();
- bitfieldMessage->setBitfield((unsigned char*)data+1, dataLength-1);
- return bitfieldMessage;
-}
-
-void BitfieldMessage::receivedAction() {
- peer->setBitfield(bitfield, bitfieldLength);
-}
-
-const char* BitfieldMessage::getMessage() {
- if(!inProgress && msg == NULL) {
- /**
- * len --- 1+bitfieldLength, 4bytes
- * id --- 5, 1byte
- * bitfield --- bitfield, len bytes
- * total: 5+len bytes
- */
- msgLength = 5+bitfieldLength;
- msg = new char[msgLength];
- PeerMessageUtil::createPeerMessageString(msg, msgLength,
- 1+bitfieldLength, ID);
- memcpy(msg+5, bitfield, bitfieldLength);
- }
- return msg;
-}
-
-int BitfieldMessage::getMessageLength() {
- getMessage();
- return msgLength;
-}
-
-void BitfieldMessage::check() const {
- PeerMessageUtil::checkBitfield(bitfield, bitfieldLength, pieces);
-}
-
-string BitfieldMessage::toString() const {
- return "bitfield "+Util::toHex(bitfield, bitfieldLength);
-}
diff --git a/src/BitfieldMessage.h b/src/BitfieldMessage.h
deleted file mode 100644
index 0764ae79..00000000
--- a/src/BitfieldMessage.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_BITFIELD_MESSAGE_H_
-#define _D_BITFIELD_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class BitfieldMessage : public SimplePeerMessage {
-private:
- unsigned char* bitfield;
- int bitfieldLength;
- // for check
- int pieces;
-
- char* msg;
- int msgLength;
-
- void init() {
- bitfield = 0;
- bitfieldLength = 0;
- pieces = 0;
- msg = 0;
- msgLength = 0;
- }
-public:
- BitfieldMessage()
- :SimplePeerMessage()
- {
- init();
- }
-
- BitfieldMessage(const unsigned char* bitfield,
- int bitfieldLength)
- :SimplePeerMessage()
- {
- init();
- setBitfield(bitfield, bitfieldLength);
- }
-
- virtual ~BitfieldMessage() {
- if(bitfield != NULL) {
- delete [] bitfield;
- }
- if(msg != NULL) {
- delete [] msg;
- }
- }
-
- enum ID_t {
- ID = 5
- };
-
- void setBitfield(const unsigned char* bitfield, int bitfieldLength);
- const unsigned char* getBitfield() const { return bitfield; }
-
- int getBitfieldLength() const { return bitfieldLength; }
-
- void setPieces(int pieces) {
- this->pieces = pieces;
- }
- int getPieces() const { return pieces;}
-
- static BitfieldMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual void check() const;
- virtual string toString() const;
-};
-
-#endif // _D_BITFIELD_MESSAGE_H_
diff --git a/src/BtHandshakeMessage.cc b/src/BtHandshakeMessage.cc
index 3cedc217..0c883d2e 100644
--- a/src/BtHandshakeMessage.cc
+++ b/src/BtHandshakeMessage.cc
@@ -57,7 +57,7 @@ void BtHandshakeMessage::init() {
reserved = new unsigned char[RESERVED_LENGTH];
infoHash = new unsigned char[INFO_HASH_LENGTH];
peerId = new unsigned char[PEER_ID_LENGTH];
- memcpy(this->pstr, PSTR, PSTR_LENGTH);
+ memcpy(this->pstr, BT_PSTR, PSTR_LENGTH);
memset(this->reserved, 0, RESERVED_LENGTH);
// fast extension
this->reserved[7] |= 0x04;
diff --git a/src/BtRequestMessage.cc b/src/BtRequestMessage.cc
index 6dffaa74..b3d5a21b 100644
--- a/src/BtRequestMessage.cc
+++ b/src/BtRequestMessage.cc
@@ -33,7 +33,6 @@
*/
/* copyright --> */
#include "BtRequestMessage.h"
-#include "PeerInteraction.h"
#include "PeerMessageUtil.h"
#include "Util.h"
#include "DlAbortEx.h"
diff --git a/src/BtSuggestPieceMessage.cc b/src/BtSuggestPieceMessage.cc
index 615fb99c..fd68d3e6 100644
--- a/src/BtSuggestPieceMessage.cc
+++ b/src/BtSuggestPieceMessage.cc
@@ -33,7 +33,6 @@
*/
/* copyright --> */
#include "BtSuggestPieceMessage.h"
-#include "PeerInteraction.h"
#include "PeerMessageUtil.h"
#include "Util.h"
#include "DlAbortEx.h"
diff --git a/src/CancelMessage.cc b/src/CancelMessage.cc
deleted file mode 100644
index 94d2ad90..00000000
--- a/src/CancelMessage.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "CancelMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "Util.h"
-#include "DlAbortEx.h"
-
-CancelMessage* CancelMessage::create(const char* data, int dataLength) {
- if(dataLength != 13) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "cancel", dataLength, 13);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "cancel", ID);
- }
- CancelMessage* cancelMessage = new CancelMessage();
- cancelMessage->setIndex(PeerMessageUtil::getIntParam(data, 1));
- cancelMessage->setBegin(PeerMessageUtil::getIntParam(data, 5));
- cancelMessage->setLength(PeerMessageUtil::getIntParam(data, 9));
- return cancelMessage;
-}
-
-void CancelMessage::receivedAction() {
- peerInteraction->rejectPieceMessageInQueue(index, begin, length);
-}
-
-const char* CancelMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 13, 4bytes
- * id --- 8, 1byte
- * index --- index, 4bytes
- * begin --- begin, 4bytes
- * length -- length, 4bytes
- * total: 17bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 13, ID);
- PeerMessageUtil::setIntParam(&msg[5], index);
- PeerMessageUtil::setIntParam(&msg[9], begin);
- PeerMessageUtil::setIntParam(&msg[13], length);
- }
- return msg;
-}
-
-int CancelMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void CancelMessage::check() const {
- PeerMessageUtil::checkIndex(index, pieces);
- PeerMessageUtil::checkBegin(begin, pieceLength);
- PeerMessageUtil::checkLength(length);
- PeerMessageUtil::checkRange(begin, length, pieceLength);
-}
-
-string CancelMessage::toString() const {
- return "cancel index="+Util::itos(index)+", begin="+Util::itos(begin)+
- ", length="+Util::itos(length);
-}
diff --git a/src/CancelMessage.h b/src/CancelMessage.h
deleted file mode 100644
index b1a15281..00000000
--- a/src/CancelMessage.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_CANCEL_MESSAGE_H_
-#define _D_CANCEL_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class CancelMessage : public SimplePeerMessage {
-private:
- int index;
- int begin;
- int length;
- // for check
- int pieces;
- int pieceLength;
-
- char msg[17];
-public:
- CancelMessage(int index = 0, int begin = 0, int length = 0)
- :SimplePeerMessage(),
- index(index),
- begin(begin),
- length(length),
- pieces(0),
- pieceLength(0) {}
-
- virtual ~CancelMessage() {}
-
- enum ID_t {
- ID = 8
- };
-
- int getIndex() const { return index; }
- void setIndex(int index) { this->index = index; }
- int getBegin() const { return begin; }
- void setBegin(int begin) { this->begin = begin; }
- int getLength() const { return length; }
- void setLength(int length) { this->length = length; }
-
- void setPieces(int pieces) {
- this->pieces = pieces;
- }
- int getPieces() const { return pieces;}
-
- void setPieceLength(int pieceLength) {
- this->pieceLength = pieceLength;
- }
- int getPieceLength() const { return pieceLength;}
-
- static CancelMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual void check() const;
- virtual string toString() const;
-};
-
-#endif // _D_CANCEL_MESSAGE_H_
diff --git a/src/ChokeMessage.cc b/src/ChokeMessage.cc
deleted file mode 100644
index d907259a..00000000
--- a/src/ChokeMessage.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "ChokeMessage.h"
-#include "PeerInteraction.h"
-#include "message.h"
-#include "PeerMessageUtil.h"
-#include "DlAbortEx.h"
-
-ChokeMessage* ChokeMessage::create(const char* data, int dataLength) {
- if(dataLength != 1) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "choke", dataLength, 1);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "choke", ID);
- }
- ChokeMessage* chokeMessage = new ChokeMessage();
- return chokeMessage;
-}
-
-void ChokeMessage::receivedAction() {
- peer->peerChoking = true;
- peerInteraction->onChoked();
-}
-
-bool ChokeMessage::sendPredicate() const {
- return !peer->amChoking;
-}
-
-const char* ChokeMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 1, 4bytes
- * id --- 0, 1byte
- * total: 5bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, ID);
- }
- return msg;
-}
-
-int ChokeMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void ChokeMessage::onSendComplete() {
- peer->amChoking = true;
- peerInteraction->rejectAllPieceMessageInQueue();
-}
-
-string ChokeMessage::toString() const {
- return "choke";
-}
diff --git a/src/ChokeMessage.h b/src/ChokeMessage.h
deleted file mode 100644
index 601b508e..00000000
--- a/src/ChokeMessage.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_CHOKE_MESSAGE_H_
-#define _D_CHOKE_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class ChokeMessage : public SimplePeerMessage {
-private:
- char msg[5];
-protected:
- virtual bool sendPredicate() const;
- virtual void onSendComplete();
-public:
- ChokeMessage():SimplePeerMessage() {}
- virtual ~ChokeMessage() {}
-
- enum ID_t {
- ID = 0
- };
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual string toString() const;
-
- static ChokeMessage* create(const char* data, int dataLength);
-};
-
-#endif // _D_CHOKE_MESSAGE_H_
diff --git a/src/HandshakeMessage.cc b/src/HandshakeMessage.cc
deleted file mode 100644
index f8c607c2..00000000
--- a/src/HandshakeMessage.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "HandshakeMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "Util.h"
-
-HandshakeMessage::HandshakeMessage() {
- init();
-}
-
-HandshakeMessage::HandshakeMessage(const unsigned char* infoHash,
- const char* peerId)
-{
- init();
- memcpy(this->infoHash, infoHash, INFO_HASH_LENGTH);
- memcpy(this->peerId, peerId, PEER_ID_LENGTH);
-}
-
-void HandshakeMessage::init() {
- this->pstrlen = 19;
- this->pstr = PSTR;
- memset(this->reserved, 0, sizeof(this->reserved));
- // fast extension
- this->reserved[7] |= 0x04;
-}
-
-HandshakeMessage* HandshakeMessage::create(const char* data, int dataLength) {
- HandshakeMessage* message = new HandshakeMessage();
- message->pstrlen = data[0];
- char pstrTemp[20];
- memcpy(pstrTemp, &data[1], sizeof(pstrTemp)-1);
- pstrTemp[sizeof(pstrTemp)-1] = '\0';
- message->pstr = pstrTemp;
- memcpy(message->reserved, &data[20], 8);
- memcpy(message->infoHash, &data[28], 20);
- memcpy(message->peerId, &data[48], 20);
- return message;
-}
-
-const char* HandshakeMessage::getMessage() {
- if(!inProgress) {
- msg[0] = pstrlen;
- memcpy(msg+1, pstr.c_str(), pstr.size());
- memcpy(msg+20, reserved, 8);
- memcpy(msg+28, infoHash, 20);
- memcpy(msg+48, peerId, 20);
- }
- return msg;
-}
-
-int HandshakeMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-string HandshakeMessage::toString() const {
- return "handshake peerId="+
- Util::urlencode((unsigned char*)peerId, sizeof(peerId))+
- " reserved="+Util::toHex(reserved, sizeof(reserved));
-}
-
-void HandshakeMessage::check() const {
- PeerMessageUtil::checkHandshake(this, btContext->getInfoHash());
-}
-
-bool HandshakeMessage::isFastExtensionSupported() const {
- return reserved[7]&0x04;
-}
diff --git a/src/HandshakeMessage.h b/src/HandshakeMessage.h
deleted file mode 100644
index 6c931c91..00000000
--- a/src/HandshakeMessage.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_HANDSHAKE_MESSAGE_H_
-#define _D_HANDSHAKE_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-#define PSTR "BitTorrent protocol"
-#define HANDSHAKE_MESSAGE_LENGTH 68
-
-class HandshakeMessage : public SimplePeerMessage {
-private:
- char msg[HANDSHAKE_MESSAGE_LENGTH];
- void init();
-public:
- char pstrlen;
- string pstr;
- unsigned char reserved[8];
- unsigned char infoHash[INFO_HASH_LENGTH];
- char peerId[PEER_ID_LENGTH];
-public:
- HandshakeMessage();
- HandshakeMessage(const unsigned char* infoHash, const char* peerId);
-
- static HandshakeMessage* create(const char* data, int dataLength);
-
- virtual ~HandshakeMessage() {}
-
- virtual int getId() const { return 999; }
- virtual void receivedAction() {};
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual void check() const;
- virtual string toString() const;
-
- bool isFastExtensionSupported() const;
-};
-
-#endif // _D_HANDSHAKE_MESSAGE_H_
diff --git a/src/HaveAllMessage.cc b/src/HaveAllMessage.cc
deleted file mode 100644
index 5947a043..00000000
--- a/src/HaveAllMessage.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "HaveAllMessage.h"
-#include "DlAbortEx.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-
-HaveAllMessage::HaveAllMessage() {}
-
-HaveAllMessage::~HaveAllMessage() {}
-
-HaveAllMessage* HaveAllMessage::create(const char* data, int dataLength) {
- if(dataLength != 1) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "have all", dataLength, 1);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "have all", ID);
- }
- HaveAllMessage* haveAllMessage = new HaveAllMessage();
- return haveAllMessage;
-}
-
-void HaveAllMessage::receivedAction() {
- if(!peer->isFastExtensionEnabled()) {
- throw new DlAbortEx("%s received while fast extension is disabled",
- toString().c_str());
- }
- peer->setAllBitfield();
-}
-
-const char* HaveAllMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 1, 4bytes
- * id --- 14, 1byte
- * total: 5bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, ID);
- }
- return msg;
-}
-
-int HaveAllMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void HaveAllMessage::check() const {}
-
-string HaveAllMessage::toString() const {
- return "have all";
-}
diff --git a/src/HaveAllMessage.h b/src/HaveAllMessage.h
deleted file mode 100644
index bea4869c..00000000
--- a/src/HaveAllMessage.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_HAVE_ALL_MESSAGE_H_
-#define _D_HAVE_ALL_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class HaveAllMessage : public SimplePeerMessage {
-private:
- char msg[5];
-public:
- HaveAllMessage();
- virtual ~HaveAllMessage();
-
- enum ID_t {
- ID = 14
- };
-
- static HaveAllMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual void check() const;
- virtual string toString() const;
-};
-
-#endif // _D_HAVE_ALL_MESSAGE_H_
diff --git a/src/HaveMessage.cc b/src/HaveMessage.cc
deleted file mode 100644
index bbf90d45..00000000
--- a/src/HaveMessage.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "HaveMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "Util.h"
-#include "DlAbortEx.h"
-
-HaveMessage* HaveMessage::create(const char* data, int dataLength) {
- if(dataLength != 5) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "have", dataLength, 5);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "have", ID);
- }
- HaveMessage* haveMessage = new HaveMessage();
- haveMessage->setIndex(PeerMessageUtil::getIntParam(data, 1));
- return haveMessage;
-}
-
-void HaveMessage::receivedAction() {
- peer->updateBitfield(index, 1);
-}
-
-bool HaveMessage::sendPredicate() const {
- return !peer->hasPiece(index);
-}
-
-const char* HaveMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 5, 4bytes
- * id --- 4, 1byte
- * piece index --- index, 4bytes
- * total: 9bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, ID);
- PeerMessageUtil::setIntParam(&msg[5], index);
- }
- return msg;
-}
-
-int HaveMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void HaveMessage::check() const {
- PeerMessageUtil::checkIndex(index, pieces);
-}
-
-string HaveMessage::toString() const {
- return "have index="+Util::itos(index);
-}
diff --git a/src/HaveMessage.h b/src/HaveMessage.h
deleted file mode 100644
index f93a0170..00000000
--- a/src/HaveMessage.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_HAVE_MESSAGE_H_
-#define _D_HAVE_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class HaveMessage : public SimplePeerMessage {
-private:
- int index;
- // for check
- int pieces;
- char msg[9];
-protected:
- virtual bool sendPredicate() const;
-public:
- HaveMessage(int index = 0)
- :SimplePeerMessage(),
- index(index),
- pieces(0) {}
-
- virtual ~HaveMessage() {}
-
- enum ID_t {
- ID = 4
- };
-
- void setIndex(int index) {
- this->index = index;
- }
- int getIndex() const { return index; }
-
- void setPieces(int pieces) {
- this->pieces = pieces;
- }
- int getPieces() const { return pieces;}
-
- static HaveMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual void check() const;
- virtual string toString() const;
-};
-
-#endif // _D_HAVE_MESSAGE_H_
diff --git a/src/HaveNoneMessage.cc b/src/HaveNoneMessage.cc
deleted file mode 100644
index 955e0621..00000000
--- a/src/HaveNoneMessage.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "HaveNoneMessage.h"
-#include "DlAbortEx.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-
-HaveNoneMessage::HaveNoneMessage() {}
-
-HaveNoneMessage::~HaveNoneMessage() {}
-
-HaveNoneMessage* HaveNoneMessage::create(const char* data, int dataLength) {
- if(dataLength != 1) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "have none", dataLength, 1);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "have none", ID);
- }
- HaveNoneMessage* haveNoneMessage = new HaveNoneMessage();
- return haveNoneMessage;
-}
-
-void HaveNoneMessage::receivedAction() {
- if(!peer->isFastExtensionEnabled()) {
- throw new DlAbortEx("%s received while fast extension is disabled",
- toString().c_str());
- }
-}
-
-const char* HaveNoneMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 1, 4bytes
- * id --- 15, 1byte
- * total: 5bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, ID);
- }
- return msg;
-}
-
-int HaveNoneMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void HaveNoneMessage::check() const {}
-
-string HaveNoneMessage::toString() const {
- return "have none";
-}
diff --git a/src/HaveNoneMessage.h b/src/HaveNoneMessage.h
deleted file mode 100644
index f3e55499..00000000
--- a/src/HaveNoneMessage.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_HAVE_NONE_MESSAGE_H_
-#define _D_HAVE_NONE_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class HaveNoneMessage : public SimplePeerMessage {
-private:
- char msg[5];
-public:
- HaveNoneMessage();
- virtual ~HaveNoneMessage();
-
- enum ID_t {
- ID = 15
- };
-
- static HaveNoneMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual void check() const;
- virtual string toString() const;
-};
-
-#endif // _D_HAVE_NONE_MESSAGE_H_
diff --git a/src/InterestedMessage.cc b/src/InterestedMessage.cc
deleted file mode 100644
index 580e57e4..00000000
--- a/src/InterestedMessage.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "InterestedMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "DlAbortEx.h"
-
-InterestedMessage* InterestedMessage::create(const char* data, int dataLength) {
- if(dataLength != 1) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "interested", dataLength, 1);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "interested", ID);
- }
- InterestedMessage* interestedMessage = new InterestedMessage();
- return interestedMessage;
-}
-
-void InterestedMessage::receivedAction() {
- peer->peerInterested = true;
-}
-
-bool InterestedMessage::sendPredicate() const {
- return !peer->amInterested;
-}
-
-const char* InterestedMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 1, 4bytes
- * id --- 2, 1byte
- * total: 5bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, ID);
- }
- return msg;
-}
-
-int InterestedMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void InterestedMessage::onSendComplete() {
- peer->amInterested = true;
-}
-
-string InterestedMessage::toString() const {
- return "interested";
-}
diff --git a/src/InterestedMessage.h b/src/InterestedMessage.h
deleted file mode 100644
index 527c38a0..00000000
--- a/src/InterestedMessage.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_INTERESTED_MESSAGE_H_
-#define _D_INTERESTED_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class InterestedMessage : public SimplePeerMessage {
-private:
- char msg[5];
-protected:
- virtual bool sendPredicate() const;
- virtual void onSendComplete();
-public:
- InterestedMessage():SimplePeerMessage() {}
- virtual ~InterestedMessage() {}
-
- enum ID_t {
- ID = 2
- };
-
- static InterestedMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual string toString() const;
-};
-
-#endif // _D_INTERESTED_MESSAGE_H_
diff --git a/src/KeepAliveMessage.cc b/src/KeepAliveMessage.cc
deleted file mode 100644
index ca919fd9..00000000
--- a/src/KeepAliveMessage.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "KeepAliveMessage.h"
-#include "PeerInteraction.h"
-
-const char* KeepAliveMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 0, 4bytes
- * total: 4bytes
- */
- memset(msg, 0, sizeof(msg));
- }
- return msg;
-}
-
-int KeepAliveMessage::getMessageLength() {
- return sizeof(msg);
-}
diff --git a/src/KeepAliveMessage.h b/src/KeepAliveMessage.h
deleted file mode 100644
index b68ab2b5..00000000
--- a/src/KeepAliveMessage.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_KEEP_ALIVE_MESSAGE_H_
-#define _D_KEEP_ALIVE_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class KeepAliveMessage : public SimplePeerMessage {
-private:
- char msg[4];
-public:
- KeepAliveMessage():SimplePeerMessage() {}
- virtual ~KeepAliveMessage() {}
-
- enum ID_t {
- ID = 99
- };
-
- virtual int getId() const { return ID; }
- virtual void receivedAction() {}
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual string toString() const {
- return "keep alive";
- }
-};
-
-#endif // _D_KEEP_ALIVE_MESSAGE_H_
diff --git a/src/Makefile.am b/src/Makefile.am
index 888d9f6c..99fe0d53 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -83,14 +83,11 @@ SRCS += MetaEntry.h\
TorrentDownloadEngine.cc TorrentDownloadEngine.h\
TorrentConsoleDownloadEngine.cc TorrentConsoleDownloadEngine.h\
PeerListenCommand.cc PeerListenCommand.h\
- PeerMessage.cc PeerMessage.h\
- HandshakeMessage.cc HandshakeMessage.h\
Piece.cc Piece.h\
RequestSlot.cc RequestSlot.h\
TorrentAutoSaveCommand.cc TorrentAutoSaveCommand.h\
Directory.cc Directory.h\
TrackerWatcherCommand.cc TrackerWatcherCommand.h\
- PeerInteraction.cc PeerInteraction.h\
MultiDiskWriter.cc MultiDiskWriter.h\
DiskAdaptor.cc DiskAdaptor.h\
CopyDiskAdaptor.cc CopyDiskAdaptor.h\
@@ -100,24 +97,6 @@ SRCS += MetaEntry.h\
TrackerUpdateCommand.cc TrackerUpdateCommand.h\
ByteArrayDiskWriter.cc ByteArrayDiskWriter.h\
PeerChokeCommand.cc PeerChokeCommand.h\
- ChokeMessage.cc ChokeMessage.h\
- UnchokeMessage.cc UnchokeMessage.h\
- InterestedMessage.cc InterestedMessage.h\
- NotInterestedMessage.cc NotInterestedMessage.h\
- HaveMessage.cc HaveMessage.h\
- BitfieldMessage.cc BitfieldMessage.h\
- RequestMessage.cc RequestMessage.h\
- PieceMessage.cc PieceMessage.h\
- CancelMessage.cc CancelMessage.h\
- KeepAliveMessage.cc KeepAliveMessage.h\
- PortMessage.cc PortMessage.h\
- HaveAllMessage.cc HaveAllMessage.h\
- HaveNoneMessage.cc HaveNoneMessage.h\
- RejectMessage.cc RejectMessage.h\
- AllowedFastMessage.cc AllowedFastMessage.h\
- SuggestPieceMessage.cc SuggestPieceMessage.h\
- SimplePeerMessage.cc SimplePeerMessage.h\
- PeerMessageFactory.cc PeerMessageFactory.h\
HaveEraseCommand.cc HaveEraseCommand.h\
TorrentRequestInfo.cc TorrentRequestInfo.h\
SeedCriteria.h\
@@ -135,7 +114,6 @@ SRCS += MetaEntry.h\
DefaultBtContext.cc DefaultBtContext.h\
PieceStorage.h\
DefaultPieceStorage.cc DefaultPieceStorage.h\
- PeerService.h\
DefaultPeerStorage.cc DefaultPeerStorage.h\
BtAnnounce.h\
DefaultBtAnnounce.cc DefaultBtAnnounce.h\
diff --git a/src/Makefile.in b/src/Makefile.in
index b1458c07..d4bea19f 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -38,6 +38,7 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = aria2c$(EXEEXT)
+# debug_new.cpp
@ENABLE_ASYNC_DNS_TRUE@am__append_1 = NameResolver.cc NameResolver.h
@ENABLE_BITTORRENT_TRUE@am__append_2 = MetaEntry.h\
@ENABLE_BITTORRENT_TRUE@ Data.cc Data.h\
@@ -55,14 +56,11 @@ bin_PROGRAMS = aria2c$(EXEEXT)
@ENABLE_BITTORRENT_TRUE@ TorrentDownloadEngine.cc TorrentDownloadEngine.h\
@ENABLE_BITTORRENT_TRUE@ TorrentConsoleDownloadEngine.cc TorrentConsoleDownloadEngine.h\
@ENABLE_BITTORRENT_TRUE@ PeerListenCommand.cc PeerListenCommand.h\
-@ENABLE_BITTORRENT_TRUE@ PeerMessage.cc PeerMessage.h\
-@ENABLE_BITTORRENT_TRUE@ HandshakeMessage.cc HandshakeMessage.h\
@ENABLE_BITTORRENT_TRUE@ Piece.cc Piece.h\
@ENABLE_BITTORRENT_TRUE@ RequestSlot.cc RequestSlot.h\
@ENABLE_BITTORRENT_TRUE@ TorrentAutoSaveCommand.cc TorrentAutoSaveCommand.h\
@ENABLE_BITTORRENT_TRUE@ Directory.cc Directory.h\
@ENABLE_BITTORRENT_TRUE@ TrackerWatcherCommand.cc TrackerWatcherCommand.h\
-@ENABLE_BITTORRENT_TRUE@ PeerInteraction.cc PeerInteraction.h\
@ENABLE_BITTORRENT_TRUE@ MultiDiskWriter.cc MultiDiskWriter.h\
@ENABLE_BITTORRENT_TRUE@ DiskAdaptor.cc DiskAdaptor.h\
@ENABLE_BITTORRENT_TRUE@ CopyDiskAdaptor.cc CopyDiskAdaptor.h\
@@ -72,24 +70,6 @@ bin_PROGRAMS = aria2c$(EXEEXT)
@ENABLE_BITTORRENT_TRUE@ TrackerUpdateCommand.cc TrackerUpdateCommand.h\
@ENABLE_BITTORRENT_TRUE@ ByteArrayDiskWriter.cc ByteArrayDiskWriter.h\
@ENABLE_BITTORRENT_TRUE@ PeerChokeCommand.cc PeerChokeCommand.h\
-@ENABLE_BITTORRENT_TRUE@ ChokeMessage.cc ChokeMessage.h\
-@ENABLE_BITTORRENT_TRUE@ UnchokeMessage.cc UnchokeMessage.h\
-@ENABLE_BITTORRENT_TRUE@ InterestedMessage.cc InterestedMessage.h\
-@ENABLE_BITTORRENT_TRUE@ NotInterestedMessage.cc NotInterestedMessage.h\
-@ENABLE_BITTORRENT_TRUE@ HaveMessage.cc HaveMessage.h\
-@ENABLE_BITTORRENT_TRUE@ BitfieldMessage.cc BitfieldMessage.h\
-@ENABLE_BITTORRENT_TRUE@ RequestMessage.cc RequestMessage.h\
-@ENABLE_BITTORRENT_TRUE@ PieceMessage.cc PieceMessage.h\
-@ENABLE_BITTORRENT_TRUE@ CancelMessage.cc CancelMessage.h\
-@ENABLE_BITTORRENT_TRUE@ KeepAliveMessage.cc KeepAliveMessage.h\
-@ENABLE_BITTORRENT_TRUE@ PortMessage.cc PortMessage.h\
-@ENABLE_BITTORRENT_TRUE@ HaveAllMessage.cc HaveAllMessage.h\
-@ENABLE_BITTORRENT_TRUE@ HaveNoneMessage.cc HaveNoneMessage.h\
-@ENABLE_BITTORRENT_TRUE@ RejectMessage.cc RejectMessage.h\
-@ENABLE_BITTORRENT_TRUE@ AllowedFastMessage.cc AllowedFastMessage.h\
-@ENABLE_BITTORRENT_TRUE@ SuggestPieceMessage.cc SuggestPieceMessage.h\
-@ENABLE_BITTORRENT_TRUE@ SimplePeerMessage.cc SimplePeerMessage.h\
-@ENABLE_BITTORRENT_TRUE@ PeerMessageFactory.cc PeerMessageFactory.h\
@ENABLE_BITTORRENT_TRUE@ HaveEraseCommand.cc HaveEraseCommand.h\
@ENABLE_BITTORRENT_TRUE@ TorrentRequestInfo.cc TorrentRequestInfo.h\
@ENABLE_BITTORRENT_TRUE@ SeedCriteria.h\
@@ -107,7 +87,6 @@ bin_PROGRAMS = aria2c$(EXEEXT)
@ENABLE_BITTORRENT_TRUE@ DefaultBtContext.cc DefaultBtContext.h\
@ENABLE_BITTORRENT_TRUE@ PieceStorage.h\
@ENABLE_BITTORRENT_TRUE@ DefaultPieceStorage.cc DefaultPieceStorage.h\
-@ENABLE_BITTORRENT_TRUE@ PeerService.h\
@ENABLE_BITTORRENT_TRUE@ DefaultPeerStorage.cc DefaultPeerStorage.h\
@ENABLE_BITTORRENT_TRUE@ BtAnnounce.h\
@ENABLE_BITTORRENT_TRUE@ DefaultBtAnnounce.cc DefaultBtAnnounce.h\
@@ -231,44 +210,29 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
UrlRequestInfo.h SpeedCalc.cc SpeedCalc.h PeerStat.h \
BitfieldMan.cc BitfieldMan.h BitfieldManFactory.cc \
BitfieldManFactory.h Randomizer.h SimpleRandomizer.cc \
- SimpleRandomizer.h debug_new.cpp NameResolver.cc \
- NameResolver.h MetaEntry.h Data.cc Data.h Dictionary.cc \
- Dictionary.h List.cc List.h MetaFileUtil.cc MetaFileUtil.h \
- MetaEntryVisitor.h ShaVisitor.cc ShaVisitor.h \
- PeerConnection.cc PeerConnection.h PeerMessageUtil.cc \
- PeerMessageUtil.h PeerAbstractCommand.cc PeerAbstractCommand.h \
- PeerInitiateConnectionCommand.cc \
+ SimpleRandomizer.h NameResolver.cc NameResolver.h MetaEntry.h \
+ Data.cc Data.h Dictionary.cc Dictionary.h List.cc List.h \
+ MetaFileUtil.cc MetaFileUtil.h MetaEntryVisitor.h \
+ ShaVisitor.cc ShaVisitor.h PeerConnection.cc PeerConnection.h \
+ PeerMessageUtil.cc PeerMessageUtil.h PeerAbstractCommand.cc \
+ PeerAbstractCommand.h PeerInitiateConnectionCommand.cc \
PeerInitiateConnectionCommand.h PeerInteractionCommand.cc \
PeerInteractionCommand.h Peer.cc Peer.h \
TorrentDownloadEngine.cc TorrentDownloadEngine.h \
TorrentConsoleDownloadEngine.cc TorrentConsoleDownloadEngine.h \
- PeerListenCommand.cc PeerListenCommand.h PeerMessage.cc \
- PeerMessage.h HandshakeMessage.cc HandshakeMessage.h Piece.cc \
- Piece.h RequestSlot.cc RequestSlot.h TorrentAutoSaveCommand.cc \
+ PeerListenCommand.cc PeerListenCommand.h Piece.cc Piece.h \
+ RequestSlot.cc RequestSlot.h TorrentAutoSaveCommand.cc \
TorrentAutoSaveCommand.h Directory.cc Directory.h \
TrackerWatcherCommand.cc TrackerWatcherCommand.h \
- PeerInteraction.cc PeerInteraction.h MultiDiskWriter.cc \
- MultiDiskWriter.h DiskAdaptor.cc DiskAdaptor.h \
- CopyDiskAdaptor.cc CopyDiskAdaptor.h DirectDiskAdaptor.cc \
- DirectDiskAdaptor.h MultiDiskAdaptor.cc MultiDiskAdaptor.h \
- FileEntry.cc FileEntry.h TrackerUpdateCommand.cc \
- TrackerUpdateCommand.h ByteArrayDiskWriter.cc \
- ByteArrayDiskWriter.h PeerChokeCommand.cc PeerChokeCommand.h \
- ChokeMessage.cc ChokeMessage.h UnchokeMessage.cc \
- UnchokeMessage.h InterestedMessage.cc InterestedMessage.h \
- NotInterestedMessage.cc NotInterestedMessage.h HaveMessage.cc \
- HaveMessage.h BitfieldMessage.cc BitfieldMessage.h \
- RequestMessage.cc RequestMessage.h PieceMessage.cc \
- PieceMessage.h CancelMessage.cc CancelMessage.h \
- KeepAliveMessage.cc KeepAliveMessage.h PortMessage.cc \
- PortMessage.h HaveAllMessage.cc HaveAllMessage.h \
- HaveNoneMessage.cc HaveNoneMessage.h RejectMessage.cc \
- RejectMessage.h AllowedFastMessage.cc AllowedFastMessage.h \
- SuggestPieceMessage.cc SuggestPieceMessage.h \
- SimplePeerMessage.cc SimplePeerMessage.h PeerMessageFactory.cc \
- PeerMessageFactory.h HaveEraseCommand.cc HaveEraseCommand.h \
- TorrentRequestInfo.cc TorrentRequestInfo.h SeedCriteria.h \
- TimeSeedCriteria.h ShareRatioSeedCriteria.h \
+ MultiDiskWriter.cc MultiDiskWriter.h DiskAdaptor.cc \
+ DiskAdaptor.h CopyDiskAdaptor.cc CopyDiskAdaptor.h \
+ DirectDiskAdaptor.cc DirectDiskAdaptor.h MultiDiskAdaptor.cc \
+ MultiDiskAdaptor.h FileEntry.cc FileEntry.h \
+ TrackerUpdateCommand.cc TrackerUpdateCommand.h \
+ ByteArrayDiskWriter.cc ByteArrayDiskWriter.h \
+ PeerChokeCommand.cc PeerChokeCommand.h HaveEraseCommand.cc \
+ HaveEraseCommand.h TorrentRequestInfo.cc TorrentRequestInfo.h \
+ SeedCriteria.h TimeSeedCriteria.h ShareRatioSeedCriteria.h \
UnionSeedCriteria.h SeedCheckCommand.cc SeedCheckCommand.h \
PeerListProcessor.h DefaultPeerListProcessor.cc \
DefaultPeerListProcessor.h CompactPeerListProcessor.cc \
@@ -276,7 +240,7 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
DelegatingPeerListProcessor.h AnnounceTier.h AnnounceList.h \
AnnounceList.cc BtContext.h DefaultBtContext.cc \
DefaultBtContext.h PieceStorage.h DefaultPieceStorage.cc \
- DefaultPieceStorage.h PeerService.h DefaultPeerStorage.cc \
+ DefaultPieceStorage.h DefaultPeerStorage.cc \
DefaultPeerStorage.h BtAnnounce.h DefaultBtAnnounce.cc \
DefaultBtAnnounce.h BtRegistry.cc BtRegistry.h BtRuntime.h \
BtProgressInfoFile.h DefaultBtProgressInfoFile.cc \
@@ -329,13 +293,10 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
@ENABLE_BITTORRENT_TRUE@ TorrentDownloadEngine.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ TorrentConsoleDownloadEngine.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ PeerListenCommand.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ PeerMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ HandshakeMessage.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ Piece.$(OBJEXT) RequestSlot.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ TorrentAutoSaveCommand.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ Directory.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ TrackerWatcherCommand.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ PeerInteraction.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ MultiDiskWriter.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ DiskAdaptor.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ CopyDiskAdaptor.$(OBJEXT) \
@@ -345,24 +306,6 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
@ENABLE_BITTORRENT_TRUE@ TrackerUpdateCommand.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ ByteArrayDiskWriter.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ PeerChokeCommand.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ ChokeMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ UnchokeMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ InterestedMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ NotInterestedMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ HaveMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ BitfieldMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ RequestMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ PieceMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ CancelMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ KeepAliveMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ PortMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ HaveAllMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ HaveNoneMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ RejectMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ AllowedFastMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ SuggestPieceMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ SimplePeerMessage.$(OBJEXT) \
-@ENABLE_BITTORRENT_TRUE@ PeerMessageFactory.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ HaveEraseCommand.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ TorrentRequestInfo.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ SeedCheckCommand.$(OBJEXT) \
@@ -429,8 +372,8 @@ am__objects_4 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
FeatureConfig.$(OBJEXT) DownloadEngineFactory.$(OBJEXT) \
UrlRequestInfo.$(OBJEXT) SpeedCalc.$(OBJEXT) \
BitfieldMan.$(OBJEXT) BitfieldManFactory.$(OBJEXT) \
- SimpleRandomizer.$(OBJEXT) debug_new.$(OBJEXT) \
- $(am__objects_1) $(am__objects_2) $(am__objects_3)
+ SimpleRandomizer.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
+ $(am__objects_3)
am_libaria2c_a_OBJECTS = $(am__objects_4)
libaria2c_a_OBJECTS = $(am_libaria2c_a_OBJECTS)
am__installdirs = "$(DESTDIR)$(bindir)"
@@ -634,8 +577,8 @@ SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \
UrlRequestInfo.h SpeedCalc.cc SpeedCalc.h PeerStat.h \
BitfieldMan.cc BitfieldMan.h BitfieldManFactory.cc \
BitfieldManFactory.h Randomizer.h SimpleRandomizer.cc \
- SimpleRandomizer.h debug_new.cpp $(am__append_1) \
- $(am__append_2) $(am__append_3)
+ SimpleRandomizer.h $(am__append_1) $(am__append_2) \
+ $(am__append_3)
noinst_LIBRARIES = libaria2c.a
libaria2c_a_SOURCES = $(SRCS)
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
@@ -652,7 +595,7 @@ AM_CPPFLAGS = -Wall\
all: all-am
.SUFFIXES:
-.SUFFIXES: .cc .cpp .o .obj
+.SUFFIXES: .cc .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -725,12 +668,10 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/alloca.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AbstractCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AbstractDiskWriter.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AllowedFastMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AnnounceList.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Base64.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitfieldMan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitfieldManFactory.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitfieldMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtAllowedFastMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtBitfieldMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtCancelMessage.Po@am__quote@
@@ -751,8 +692,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtSuggestPieceMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtUnchokeMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ByteArrayDiskWriter.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CancelMessage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChokeMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkedEncoding.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Command.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CompactPeerListProcessor.Po@am__quote@
@@ -789,11 +728,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FtpNegotiationCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FtpTunnelRequestCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FtpTunnelResponseCommand.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HandshakeMessage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HaveAllMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HaveEraseCommand.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HaveMessage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HaveNoneMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpConnection.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpDownloadCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpHeader.Po@am__quote@
@@ -803,8 +738,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpRequestCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpResponseCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InitiateConnectionCommandFactory.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InterestedMessage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/KeepAliveMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/List.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogFactory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetaFileUtil.Po@am__quote@
@@ -815,26 +748,18 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MultiDiskAdaptor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MultiDiskWriter.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NameResolver.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NotInterestedMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Option.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Peer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerAbstractCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerChokeCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerConnection.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerInitiateConnectionCommand.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerInteraction.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerInteractionCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerListenCommand.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerMessage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerMessageFactory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerMessageUtil.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Piece.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PieceMessage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PortMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PreAllocationDiskWriter.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RejectMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestSlot.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SeedCheckCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Segment.Po@am__quote@
@@ -842,12 +767,10 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ShaVisitor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimpleBtMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimpleLogger.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimplePeerMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimpleRandomizer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SleepCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SocketCore.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SpeedCalc.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SuggestPieceMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeA2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TorrentAutoSaveCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TorrentConsoleDownloadEngine.Po@am__quote@
@@ -855,11 +778,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TorrentRequestInfo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerUpdateCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerWatcherCommand.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnchokeMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UrlRequestInfo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xml2MetalinkProcessor.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug_new.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
.cc.o:
@@ -875,20 +796,6 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-.cpp.o:
-@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
-@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
-
-.cpp.obj:
-@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
-@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
diff --git a/src/NotInterestedMessage.cc b/src/NotInterestedMessage.cc
deleted file mode 100644
index d596a9d7..00000000
--- a/src/NotInterestedMessage.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "NotInterestedMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "DlAbortEx.h"
-
-NotInterestedMessage* NotInterestedMessage::create(const char* data, int dataLength) {
- if(dataLength != 1) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "not interested", dataLength, 1);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "not interested", ID);
- }
- NotInterestedMessage* notInterestedMessage = new NotInterestedMessage();
- return notInterestedMessage;
-}
-
-void NotInterestedMessage::receivedAction() {
- peer->peerInterested = false;
-}
-
-bool NotInterestedMessage::sendPredicate() const {
- return peer->amInterested;
-}
-
-const char* NotInterestedMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 1, 4bytes
- * id --- 3, 1byte
- * total: 5bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, ID);
- }
- return msg;
-}
-
-int NotInterestedMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void NotInterestedMessage::onSendComplete() {
- peer->amInterested = false;
-}
-
-string NotInterestedMessage::toString() const {
- return "not interested";
-}
diff --git a/src/NotInterestedMessage.h b/src/NotInterestedMessage.h
deleted file mode 100644
index 669fedc2..00000000
--- a/src/NotInterestedMessage.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_NOT_INTERESTED_MESSAGE_H_
-#define _D_NOT_INTERESTED_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class NotInterestedMessage : public SimplePeerMessage {
-private:
- char msg[5];
-protected:
- virtual bool sendPredicate() const;
- virtual void onSendComplete();
-public:
- NotInterestedMessage():SimplePeerMessage() {}
- virtual ~NotInterestedMessage() {}
-
- enum ID_t {
- ID = 3
- };
-
- static NotInterestedMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual string toString() const;
-};
-
-#endif // _D_NOT_INTERESTED_MESSAGE_H_
diff --git a/src/PeerInteraction.cc b/src/PeerInteraction.cc
deleted file mode 100644
index bed01a01..00000000
--- a/src/PeerInteraction.cc
+++ /dev/null
@@ -1,453 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "PeerInteraction.h"
-#include "LogFactory.h"
-#include "DlAbortEx.h"
-#include "KeepAliveMessage.h"
-#include "PeerMessageUtil.h"
-#include "Util.h"
-#include "prefs.h"
-#include "BtRegistry.h"
-#include <netinet/in.h>
-
-PeerInteraction::PeerInteraction(int cuid,
- const PeerHandle& peer,
- const SocketHandle& socket,
- const Option* op,
- const BtContextHandle& btContext)
- :cuid(cuid),
- option(op),
- btContext(btContext),
- peerStorage(PEER_STORAGE(btContext)),
- pieceStorage(PIECE_STORAGE(btContext)),
- btAnnounce(BT_ANNOUNCE(btContext)),
- peer(peer),
- quickReplied(false) {
- peerConnection = new PeerConnection(cuid, socket, op);
- peerMessageFactory = new PeerMessageFactory(cuid, btContext, this, peer);
- logger = LogFactory::getInstance();
-}
-
-PeerInteraction::~PeerInteraction() {
- delete peerConnection;
- delete peerMessageFactory;
-}
-
-bool PeerInteraction::isSendingMessageInProgress() const {
- if(messageQueue.size() > 0) {
- const PeerMessageHandle& peerMessage = messageQueue.front();
- if(peerMessage->isInProgress()) {
- return true;
- }
- }
- return false;
-}
-
-void PeerInteraction::sendMessages() {
- MessageQueue tempQueue;
- int uploadLimit = option->getAsInt(PREF_MAX_UPLOAD_LIMIT);
- while(messageQueue.size() > 0) {
- PeerMessageHandle msg = messageQueue.front();
- messageQueue.pop_front();
- if(uploadLimit > 0) {
- TransferStat stat = peerStorage->calculateStat();
- if(uploadLimit < stat.uploadSpeed &&
- msg->isUploading() && !msg->isInProgress()) {
- tempQueue.push_back(msg);
- continue;
- }
- }
- msg->send();
- if(msg->isInProgress()) {
- messageQueue.push_front(msg);
- break;
- }
- }
- copy(tempQueue.begin(), tempQueue.end(), back_inserter(messageQueue));
-}
-
-void PeerInteraction::addMessage(const PeerMessageHandle& peerMessage) {
- peerMessage->onPush();
- messageQueue.push_back(peerMessage);
-}
-
-void PeerInteraction::addRequestSlot(const RequestSlot& requestSlot) {
- requestSlots.push_back(requestSlot);
-}
-
-void PeerInteraction::rejectAllPieceMessageInQueue() {
- int size = messageQueue.size();
- for(int i = 0; i < size; i++) {
- messageQueue.at(i)->onChoked();
- }
-}
-
-void PeerInteraction::rejectPieceMessageInQueue(int index, int begin, int length) {
- int size = messageQueue.size();
- for(int i = 0; i < size; i++) {
- messageQueue.at(i)->onCanceled(index, begin, length);
- }
-}
-
-void PeerInteraction::onChoked() {
- for(Pieces::iterator itr = pieces.begin(); itr != pieces.end();) {
- PieceHandle& piece = *itr;
- if(!peer->isInFastSet(piece->getIndex())) {
- abortPiece(piece);
- itr = pieces.erase(itr);
- } else {
- itr++;
- }
- }
-}
-
-void PeerInteraction::abortAllPieces() {
- for(Pieces::iterator itr = pieces.begin(); itr != pieces.end();) {
- abortPiece(*itr);
- itr = pieces.erase(itr);
- }
-}
-
-void PeerInteraction::abortPiece(const PieceHandle& piece) {
- if(!piece.isNull()) {
- int size = messageQueue.size();
- for(int i = 0; i < size; i++) {
- messageQueue.at(i)->onAbortPiece(piece);
- }
- for(RequestSlots::iterator itr = requestSlots.begin();
- itr != requestSlots.end();) {
- if(itr->getIndex() == piece->getIndex()) {
- logger->debug("CUID#%d - Deleting request slot blockIndex=%d"
- " because piece was canceled",
- cuid,
- itr->getBlockIndex());
- piece->cancelBlock(itr->getBlockIndex());
- itr = requestSlots.erase(itr);
- } else {
- itr++;
- }
- }
- pieceStorage->cancelPiece(piece);
- }
-}
-
-
-void PeerInteraction::deleteRequestSlot(const RequestSlot& requestSlot) {
- RequestSlots::iterator itr = find(requestSlots.begin(), requestSlots.end(),
- requestSlot);
- if(itr != requestSlots.end()) {
- requestSlots.erase(itr);
- }
-}
-
-void PeerInteraction::checkRequestSlot() {
- for(RequestSlots::iterator itr = requestSlots.begin();
- itr != requestSlots.end();) {
- RequestSlot& slot = *itr;
- if(slot.isTimeout(REQUEST_TIME_OUT)) {
- logger->debug("CUID#%d - Deleting request slot blockIndex=%d"
- " because of time out",
- cuid,
- slot.getBlockIndex());
- PieceHandle piece = getDownloadPiece(slot.getIndex());
- piece->cancelBlock(slot.getBlockIndex());
- itr = requestSlots.erase(itr);
- peer->snubbing = true;
- } else {
- PieceHandle piece = getDownloadPiece(slot.getIndex());
- if(piece->hasBlock(slot.getBlockIndex()) ||
- pieceStorage->hasPiece(piece->getIndex())) {
- logger->debug("CUID#%d - Deleting request slot blockIndex=%d because"
- " the block has been acquired.", cuid,
- slot.getBlockIndex());
- addMessage(peerMessageFactory->createCancelMessage(slot.getIndex(),
- slot.getBegin(),
- slot.getLength()));
- itr = requestSlots.erase(itr);
- } else {
- itr++;
- }
- }
- }
- updatePiece();
-}
-
-bool PeerInteraction::isInRequestSlot(int index, int blockIndex) const {
- for(RequestSlots::const_iterator itr = requestSlots.begin();
- itr != requestSlots.end(); itr++) {
- const RequestSlot& slot = *itr;
- if(slot.getIndex() == index && slot.getBlockIndex() == blockIndex) {
- return true;
- }
- }
- return false;
-}
-
-RequestSlot PeerInteraction::getCorrespondingRequestSlot(int index,
- int begin,
- int length) const {
- for(RequestSlots::const_iterator itr = requestSlots.begin();
- itr != requestSlots.end(); itr++) {
- const RequestSlot& slot = *itr;
- if(slot.getIndex() == index &&
- slot.getBegin() == begin &&
- slot.getLength() == length) {
- return slot;
- }
- }
- return RequestSlot::nullSlot;
-}
-
-int PeerInteraction::countMessageInQueue() const {
- return messageQueue.size();
-}
-
-int PeerInteraction::countRequestSlot() const {
- return requestSlots.size();
-}
-
-PeerMessageHandle PeerInteraction::receiveHandshake(bool quickReply) {
- char msg[HANDSHAKE_MESSAGE_LENGTH];
- int msgLength = HANDSHAKE_MESSAGE_LENGTH;
- bool retval = peerConnection->receiveHandshake(msg, msgLength);
- // To handle tracker's NAT-checking feature
- if(!quickReplied && quickReply && msgLength >= 48) {
- quickReplied = true;
- // check info_hash
- if(memcmp(btContext->getInfoHash(), &msg[28], INFO_HASH_LENGTH) == 0) {
- sendHandshake();
- }
- }
- if(!retval) {
- return NULL;
- }
- PeerMessageHandle handshakeMessage(peerMessageFactory->createHandshakeMessage(msg, msgLength));
- handshakeMessage->check();
- if(((HandshakeMessage*)handshakeMessage.get())->isFastExtensionSupported()) {
- peer->setFastExtensionEnabled(true);
- logger->info("CUID#%d - Fast extension enabled.", cuid);
- }
- return handshakeMessage;
-}
-
-PeerMessageHandle PeerInteraction::receiveMessage() {
- char msg[MAX_PAYLOAD_LEN];
- int msgLength = 0;
- if(!peerConnection->receiveMessage(msg, msgLength)) {
- return NULL;
- }
- PeerMessageHandle peerMessage =
- peerMessageFactory->createPeerMessage(msg, msgLength);
- peerMessage->check();
- return peerMessage;
-}
-
-void PeerInteraction::syncPiece() {
- /*
- for(Pieces::iterator itr = pieces.begin(); itr != pieces.end(); itr++) {
- pieceStorage->syncPiece(*itr);
- }
- */
-}
-
-void PeerInteraction::updatePiece() {
- /*
- for(Pieces::iterator itr = pieces.begin(); itr != pieces.end(); itr++) {
- pieceStorage->updatePiece(*itr);
- }
- */
-}
-
-void PeerInteraction::getNewPieceAndSendInterest(int pieceNum) {
- if(pieces.empty() && !pieceStorage->hasMissingPiece(peer)) {
- if(peer->amInterested) {
- logger->debug("CUID#%d - Not interested in the peer", cuid);
- addMessage(peerMessageFactory->createNotInterestedMessage());
- }
- } else {
- if(peer->peerChoking) {
- onChoked();
- if(peer->isFastExtensionEnabled()) {
- while((int)pieces.size() < pieceNum) {
- PieceHandle piece = pieceStorage->getMissingFastPiece(peer);
- if(piece.isNull()) {
- break;
- } else {
- pieces.push_back(piece);
- }
- }
- }
- } else {
- while((int)pieces.size() < pieceNum) {
- PieceHandle piece = pieceStorage->getMissingPiece(peer);
- if(piece.isNull()) {
- break;
- } else {
- pieces.push_back(piece);
- }
- }
- }
- if(!peer->amInterested) {
- logger->debug("CUID#%d - Interested in the peer", cuid);
- addMessage(peerMessageFactory->createInterestedMessage());
- }
- }
-}
-
-void PeerInteraction::addRequests() {
- // Abort downloading of completed piece.
- for(Pieces::iterator itr = pieces.begin(); itr != pieces.end();) {
- PieceHandle& piece = *itr;
- if(piece->pieceComplete()) {
- abortPiece(piece);
- itr = pieces.erase(itr);
- } else {
- itr++;
- }
- }
- int MAX_PENDING_REQUEST;
- if(peer->getLatency() < 500) {
- MAX_PENDING_REQUEST = 24;
- } else if(peer->getLatency() < 1500) {
- MAX_PENDING_REQUEST = 12;
- } else {
- MAX_PENDING_REQUEST = 6;
- }
- int pieceNum;
- if(pieceStorage->isEndGame()) {
- pieceNum = 1;
- } else {
- int blocks = DIV_FLOOR(btContext->getPieceLength(), BLOCK_LENGTH);
- pieceNum = DIV_FLOOR(MAX_PENDING_REQUEST, blocks);
- }
- getNewPieceAndSendInterest(pieceNum);
- for(Pieces::iterator itr = pieces.begin(); itr != pieces.end(); itr++) {
- PieceHandle& piece = *itr;
- if(pieceStorage->isEndGame()) {
- BlockIndexes missingBlockIndexes = piece->getAllMissingBlockIndexes();
- random_shuffle(missingBlockIndexes.begin(), missingBlockIndexes.end());
- int count = countRequestSlot();
- for(BlockIndexes::const_iterator bitr = missingBlockIndexes.begin();
- bitr != missingBlockIndexes.end() && count < MAX_PENDING_REQUEST;
- bitr++) {
- int blockIndex = *bitr;
- if(!isInRequestSlot(piece->getIndex(), blockIndex)) {
- addMessage(peerMessageFactory->createRequestMessage(piece,
- blockIndex));
- count++;
- }
- }
- } else {
- while(countRequestSlot() < MAX_PENDING_REQUEST) {
- int blockIndex = piece->getMissingUnusedBlockIndex();
- if(blockIndex == -1) {
- break;
- }
- addMessage(peerMessageFactory->createRequestMessage(piece,
- blockIndex));
- }
- }
- if(countRequestSlot() >= MAX_PENDING_REQUEST) {
- break;
- }
- }
- updatePiece();
-}
-
-void PeerInteraction::sendHandshake() {
- PeerMessageHandle handle =
- peerMessageFactory->createHandshakeMessage(btContext->getInfoHash(),
- (const char*)btContext->getPeerId());
- addMessage(handle);
- sendMessages();
-}
-
-void PeerInteraction::sendBitfield() {
- if(peer->isFastExtensionEnabled()) {
- if(pieceStorage->downloadFinished()) {
- addMessage(peerMessageFactory->createHaveAllMessage());
- } else if(pieceStorage->getCompletedLength() > 0) {
- addMessage(peerMessageFactory->createBitfieldMessage());
- } else {
- addMessage(peerMessageFactory->createHaveNoneMessage());
- }
- } else {
- if(pieceStorage->getCompletedLength() > 0) {
- addMessage(peerMessageFactory->createBitfieldMessage());
- }
- }
- sendMessages();
-}
-
-void PeerInteraction::sendAllowedFast() {
- if(peer->isFastExtensionEnabled()) {
- Integers fastSet = Util::computeFastSet(peer->ipaddr,
- btContext->getInfoHash(),
- btContext->getNumPieces(),
- ALLOWED_FAST_SET_SIZE);
- for(Integers::const_iterator itr = fastSet.begin();
- itr != fastSet.end(); itr++) {
- addMessage(peerMessageFactory->createAllowedFastMessage(*itr));
- }
- }
-}
-
-PieceHandle PeerInteraction::getDownloadPiece(int index) {
- for(Pieces::iterator itr = pieces.begin(); itr != pieces.end(); itr++) {
- if((*itr)->getIndex() == index) {
- return *itr;
- }
- }
- throw new DlAbortEx("No such piece index=%d", index);
-}
-
-bool PeerInteraction::hasDownloadPiece(int index) const {
- for(Pieces::const_iterator itr = pieces.begin(); itr != pieces.end(); itr++) {
- if((*itr)->getIndex() == index) {
- return true;
- }
- }
- return false;
-}
-
-bool PeerInteraction::isInFastSet(int index) const {
- return find(fastSet.begin(), fastSet.end(), index) != fastSet.end();
-}
-
-void PeerInteraction::addFastSetIndex(int index) {
- if(!isInFastSet(index)) {
- fastSet.push_back(index);
- }
-}
diff --git a/src/PeerInteraction.h b/src/PeerInteraction.h
deleted file mode 100644
index de2d5d57..00000000
--- a/src/PeerInteraction.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_PEER_INTERACTION_H_
-#define _D_PEER_INTERACTION_H_
-
-#include "common.h"
-#include "PeerConnection.h"
-#include "PeerMessageFactory.h"
-#include "RequestSlot.h"
-#include "SharedHandle.h"
-#include "BtContext.h"
-#include "PeerStorage.h"
-#include "PieceStorage.h"
-#include "BtAnnounce.h"
-
-#define REQUEST_TIME_OUT 60
-#define ALLOWED_FAST_SET_SIZE 10
-
-typedef deque<PeerMessageHandle> MessageQueue;
-
-class PeerInteraction {
-private:
- int cuid;
- RequestSlots requestSlots;
- MessageQueue messageQueue;
- const Option* option;
- BtContextHandle btContext;
- PeerStorageHandle peerStorage;
- PieceStorageHandle pieceStorage;
- BtAnnounceHandle btAnnounce;
- PeerConnection* peerConnection;
- PeerHandle peer;
- Pieces pieces;
- PeerMessageFactory* peerMessageFactory;
- // allowed fast piece indexes that local client has sent
- Integers fastSet;
- bool quickReplied;
- const Logger* logger;
-
- void getNewPieceAndSendInterest(int pieceNum);
- int countRequestSlot() const;
-public:
- PeerInteraction(int cuid,
- const PeerHandle& peer,
- const SocketHandle& socket,
- const Option* op,
- const BtContextHandle& btContext);
- ~PeerInteraction();
-
- void addMessage(const PeerMessageHandle& peerMessage);
- void addRequestSlot(const RequestSlot& requestSlot);
- void rejectPieceMessageInQueue(int index, int begin, int length);
- void rejectAllPieceMessageInQueue();
- void onChoked();
- void abortPiece(const PieceHandle& piece);
- void abortAllPieces();
-
- bool isSendingMessageInProgress() const;
- void deleteRequestSlot(const RequestSlot& requestSlot);
- void checkRequestSlot();
- RequestSlot getCorrespondingRequestSlot(int index, int begin, int length) const;
- bool isInRequestSlot(int index, int blockIndex) const;
-
- int countMessageInQueue() const;
-
- PeerConnection* getPeerConnection() const { return peerConnection; }
-
- // If this object has nullPiece, then return false, otherwise true
- bool hasDownloadPiece(int index) const;
-
- // If the piece which this object has is nullPiece, then throws an exception.
- // So before calling this function, call hasDownloadPiece and make sure
- // this has valid piece, not nullPiece.
- PieceHandle getDownloadPiece(int index);
-
- bool isInFastSet(int index) const;
-
- void addFastSetIndex(int index);
-
- void syncPiece();
- void updatePiece();
- void addRequests();
- void sendMessages();
- void sendHandshake();
- void sendBitfield();
- void sendAllowedFast();
-
- PeerMessageHandle receiveMessage();
- PeerMessageHandle receiveHandshake(bool quickReply = false);
-
- const PeerMessageFactory* getPeerMessageFactory() const {
- return peerMessageFactory;
- }
-};
-
-#endif // _D_PEER_INTERACTION_H_
diff --git a/src/PeerMessage.cc b/src/PeerMessage.cc
deleted file mode 100644
index 2ce7903b..00000000
--- a/src/PeerMessage.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "PeerMessage.h"
-#include "LogFactory.h"
-
-PeerMessage::PeerMessage()
- :inProgress(false),
- invalidate(false),
- uploading(false),
- peer(0),
- btContext(0),
- peerStorage(0),
- pieceStorage(0)
- {
- logger = LogFactory::getInstance();
-}
diff --git a/src/PeerMessage.h b/src/PeerMessage.h
deleted file mode 100644
index ebe581c3..00000000
--- a/src/PeerMessage.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_PEER_MESSAGE_H_
-#define _D_PEER_MESSAGE_H_
-
-#include "common.h"
-#include "Logger.h"
-#include "Peer.h"
-#include "Piece.h"
-#include "BtContext.h"
-#include "PeerStorage.h"
-#include "PieceStorage.h"
-#include "BtRegistry.h"
-#include <string>
-
-class PeerInteraction;
-
-class PeerMessage {
-protected:
- bool inProgress;
- bool invalidate;
- bool uploading;
- int cuid;
- PeerHandle peer;
- PeerInteraction* peerInteraction;
- const Logger* logger;
- BtContextHandle btContext;
- PeerStorageHandle peerStorage;
- PieceStorageHandle pieceStorage;
-public:
- PeerMessage();
-
- virtual ~PeerMessage() {}
-
- bool isInProgress() const { return inProgress; }
- bool isInvalidate() const { return invalidate; }
- bool isUploading() const { return uploading; }
-
- int getCuid() const { return cuid; }
-
- void setCuid(int cuid) {
- this->cuid = cuid;
- }
-
- PeerHandle getPeer() const { return this->peer; }
-
- void setPeer(const PeerHandle& peer) {
- this->peer = peer;
- }
-
- PeerInteraction* getPeerInteraction() const { return peerInteraction; }
-
- void setPeerInteraction(PeerInteraction* peerInteraction) {
- this->peerInteraction = peerInteraction;
- }
-
- void setBtContext(const BtContextHandle& btContext) {
- this->btContext = btContext;
- pieceStorage = PIECE_STORAGE(btContext);
- peerStorage = PEER_STORAGE(btContext);
- }
-
- virtual int getId() const = 0;
- virtual void receivedAction() = 0;
- virtual void send() = 0;
- virtual void check() const {}
- virtual string toString() const = 0;
- virtual void onPush() {}
- virtual void onChoked() {}
- virtual void onCanceled(int index, int begin, int blockLength) {}
- virtual void onAbortPiece(const PieceHandle& piece) {}
-};
-
-typedef SharedHandle<PeerMessage> PeerMessageHandle;
-
-#endif // _D_PEER_MESSAGE_H_
diff --git a/src/PeerMessageFactory.cc b/src/PeerMessageFactory.cc
deleted file mode 100644
index f3f4b810..00000000
--- a/src/PeerMessageFactory.cc
+++ /dev/null
@@ -1,281 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "PeerMessageFactory.h"
-#include "PeerMessageUtil.h"
-#include "ChokeMessage.h"
-#include "UnchokeMessage.h"
-#include "InterestedMessage.h"
-#include "NotInterestedMessage.h"
-#include "HaveMessage.h"
-#include "BitfieldMessage.h"
-#include "RequestMessage.h"
-#include "CancelMessage.h"
-#include "PieceMessage.h"
-#include "HandshakeMessage.h"
-#include "KeepAliveMessage.h"
-#include "PortMessage.h"
-#include "HaveAllMessage.h"
-#include "HaveNoneMessage.h"
-#include "RejectMessage.h"
-#include "AllowedFastMessage.h"
-#include "SuggestPieceMessage.h"
-#include "RequestSlot.h"
-#include "DlAbortEx.h"
-#include "BtRegistry.h"
-#include "PeerInteraction.h"
-
-PeerMessageFactory::PeerMessageFactory(int cuid,
- const BtContextHandle& btContext,
- PeerInteraction* peerInteraction,
- const PeerHandle& peer)
- :cuid(cuid),
- btContext(btContext),
- pieceStorage(PIECE_STORAGE(btContext)),
- peerInteraction(peerInteraction),
- peer(peer) {}
-
-PeerMessageFactory::~PeerMessageFactory() {}
-
-PeerMessageHandle PeerMessageFactory::createPeerMessage(const char* msg, int msgLength) const {
- PeerMessage* peerMessage;
- if(msgLength == 0) {
- // keep-alive
- peerMessage = new KeepAliveMessage();
- } else {
- int id = PeerMessageUtil::getId(msg);
- switch(id) {
- case ChokeMessage::ID:
- peerMessage = ChokeMessage::create(msg, msgLength);
- break;
- case UnchokeMessage::ID:
- peerMessage = UnchokeMessage::create(msg, msgLength);
- break;
- case InterestedMessage::ID:
- peerMessage = InterestedMessage::create(msg, msgLength);
- break;
- case NotInterestedMessage::ID:
- peerMessage = NotInterestedMessage::create(msg, msgLength);
- break;
- case HaveMessage::ID:
- peerMessage = HaveMessage::create(msg, msgLength);
- ((HaveMessage*)peerMessage)->setPieces(btContext->getNumPieces());
- break;
- case BitfieldMessage::ID:
- peerMessage = BitfieldMessage::create(msg, msgLength);
- ((BitfieldMessage*)peerMessage)->setPieces(btContext->getNumPieces());
- break;
- case RequestMessage::ID:
- peerMessage = RequestMessage::create(msg, msgLength);
- ((RequestMessage*)peerMessage)->setPieces(btContext->getNumPieces());
- ((RequestMessage*)peerMessage)->setPieceLength(pieceStorage->getPieceLength(((RequestMessage*)peerMessage)->getIndex()));
- break;
- case CancelMessage::ID:
- peerMessage = CancelMessage::create(msg, msgLength);
- ((CancelMessage*)peerMessage)->setPieces(btContext->getNumPieces());
- ((CancelMessage*)peerMessage)->setPieceLength(pieceStorage->getPieceLength(((CancelMessage*)peerMessage)->getIndex()));
- break;
- case PieceMessage::ID:
- peerMessage = PieceMessage::create(msg, msgLength);
- ((PieceMessage*)peerMessage)->setPieces(btContext->getNumPieces());
- ((PieceMessage*)peerMessage)->setPieceLength(pieceStorage->getPieceLength(((PieceMessage*)peerMessage)->getIndex()));
- break;
- case PortMessage::ID:
- peerMessage = PortMessage::create(msg, msgLength);
- break;
- case HaveAllMessage::ID:
- peerMessage = HaveAllMessage::create(msg, msgLength);
- break;
- case HaveNoneMessage::ID:
- peerMessage = HaveNoneMessage::create(msg, msgLength);
- break;
- case RejectMessage::ID:
- peerMessage = RejectMessage::create(msg, msgLength);
- ((RejectMessage*)peerMessage)->setPieces(btContext->getNumPieces());
- ((RejectMessage*)peerMessage)->setPieceLength(pieceStorage->getPieceLength(((RejectMessage*)peerMessage)->getIndex()));
- break;
- case SuggestPieceMessage::ID:
- peerMessage = SuggestPieceMessage::create(msg, msgLength);
- ((SuggestPieceMessage*)peerMessage)->setPieces(btContext->getNumPieces());
- break;
- case AllowedFastMessage::ID:
- peerMessage = AllowedFastMessage::create(msg, msgLength);
- ((AllowedFastMessage*)peerMessage)->setPieces(btContext->getNumPieces());
- break;
- default:
- throw new DlAbortEx("Invalid message id. id = %d", id);
- }
- }
- PeerMessageHandle handle = PeerMessageHandle(peerMessage);
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle
-PeerMessageFactory::createHandshakeMessage(const char* msg, int msgLength) const
-{
- PeerMessageHandle handle =
- PeerMessageHandle(HandshakeMessage::create(msg, msgLength));
-
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle
-PeerMessageFactory::createHandshakeMessage(const unsigned char* infoHash,
- const char* peerId) const
-{
- PeerMessageHandle handle =
- PeerMessageHandle(new HandshakeMessage(infoHash, peerId));
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-void
-PeerMessageFactory::setPeerMessageCommonProperty(PeerMessageHandle& peerMessage) const
-{
- peerMessage->setPeer(peer);
- peerMessage->setCuid(cuid);
- peerMessage->setPeerInteraction(peerInteraction);
- peerMessage->setBtContext(btContext);
-}
-
-PeerMessageHandle PeerMessageFactory::createRequestMessage(const PieceHandle& piece,
- int blockIndex) const {
- PeerMessageHandle handle =
- PeerMessageHandle(new RequestMessage(piece->getIndex(),
- blockIndex*piece->getBlockLength(),
- piece->getBlockLength(blockIndex),
- blockIndex));
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createCancelMessage(int index,
- int begin,
- int length) const {
- PeerMessageHandle handle =
- PeerMessageHandle(new CancelMessage(index, begin, length));
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createPieceMessage(int index,
- int begin,
- int length) const {
- PeerMessageHandle handle =
- PeerMessageHandle(new PieceMessage(index, begin, length));
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createHaveMessage(int index) const {
- PeerMessageHandle handle =
- PeerMessageHandle(new HaveMessage(index));
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createChokeMessage() const {
- PeerMessageHandle handle =
- PeerMessageHandle(new ChokeMessage());
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createUnchokeMessage() const {
- PeerMessageHandle handle =
- PeerMessageHandle(new UnchokeMessage());
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createInterestedMessage() const {
- PeerMessageHandle handle =
- PeerMessageHandle(new InterestedMessage());
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createNotInterestedMessage() const {
- PeerMessageHandle handle =
- PeerMessageHandle(new NotInterestedMessage());
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createBitfieldMessage() const {
- PeerMessageHandle handle =
- PeerMessageHandle(new BitfieldMessage(pieceStorage->getBitfield(),
- pieceStorage->getBitfieldLength()));
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createKeepAliveMessage() const {
- PeerMessageHandle handle =
- PeerMessageHandle(new KeepAliveMessage());
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createHaveAllMessage() const {
- PeerMessageHandle handle =
- PeerMessageHandle(new HaveAllMessage());
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createHaveNoneMessage() const {
- PeerMessageHandle handle =
- PeerMessageHandle(new HaveNoneMessage());
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createRejectMessage(int index,
- int begin,
- int length) const {
- PeerMessageHandle handle =
- PeerMessageHandle(new RejectMessage(index, begin, length));
- setPeerMessageCommonProperty(handle);
- return handle;
-}
-
-PeerMessageHandle PeerMessageFactory::createAllowedFastMessage(int index) const {
- PeerMessageHandle handle =
- PeerMessageHandle(new AllowedFastMessage(index));
- setPeerMessageCommonProperty(handle);
- return handle;
-}
diff --git a/src/PeerMessageFactory.h b/src/PeerMessageFactory.h
deleted file mode 100644
index 7d7856f7..00000000
--- a/src/PeerMessageFactory.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_PEER_MESSAGE_FACTORY_H_
-#define _D_PEER_MESSAGE_FACTORY_H_
-
-#include "common.h"
-#include "PeerMessage.h"
-#include "HandshakeMessage.h"
-#include "BtContext.h"
-#include "PieceStorage.h"
-
-class PeerInteraction;
-
-class PeerMessageFactory {
-private:
- int cuid;
- BtContextHandle btContext;
- PieceStorageHandle pieceStorage;
- PeerInteraction* peerInteraction;
- PeerHandle peer;
-
- void setPeerMessageCommonProperty(PeerMessageHandle& peerMessage) const;
-public:
- PeerMessageFactory(int cuid,
- const BtContextHandle& btContext,
- PeerInteraction* peerInteraction,
- const PeerHandle& peer);
-
- ~PeerMessageFactory();
-
- PeerMessageHandle
- createPeerMessage(const char* msg, int msgLength) const;
-
- PeerMessageHandle
- createHandshakeMessage(const char* msg,
- int msgLength) const;
-
- PeerMessageHandle
- createHandshakeMessage(const unsigned char* infoHash,
- const char* peerId) const;
-
- PeerMessageHandle createRequestMessage(const PieceHandle& piece,
- int blockIndex) const;
- PeerMessageHandle createCancelMessage(int index, int begin, int length) const;
- PeerMessageHandle createPieceMessage(int index, int begin, int length) const;
- PeerMessageHandle createHaveMessage(int index) const;
- PeerMessageHandle createChokeMessage() const;
- PeerMessageHandle createUnchokeMessage() const;
- PeerMessageHandle createInterestedMessage() const;
- PeerMessageHandle createNotInterestedMessage() const;
- PeerMessageHandle createBitfieldMessage() const;
- PeerMessageHandle createKeepAliveMessage() const;
- PeerMessageHandle createHaveAllMessage() const;
- PeerMessageHandle createHaveNoneMessage() const;
- PeerMessageHandle createRejectMessage(int index, int begin, int length) const;
- PeerMessageHandle createAllowedFastMessage(int index) const;
-};
-
-#endif // _D_PEER_MESSAGE_FACTORY_H_
diff --git a/src/PeerMessageUtil.cc b/src/PeerMessageUtil.cc
index 33cfe7be..21bd28ec 100644
--- a/src/PeerMessageUtil.cc
+++ b/src/PeerMessageUtil.cc
@@ -106,21 +106,6 @@ void PeerMessageUtil::checkBitfield(const unsigned char* bitfield,
}
}
-void PeerMessageUtil::checkHandshake(const HandshakeMessage* message, const unsigned char* infoHash) {
- if(message->pstrlen != 19) {
- throw new DlAbortEx("invalid handshake pstrlen = %d", (int)message->pstrlen);
- }
- if(message->pstr != PSTR) {
- throw new DlAbortEx("invalid handshake pstr");
- }
- string myInfoHash = Util::toHex(infoHash, 20);
- string peerInfoHash = Util::toHex(message->infoHash, 20);
- if(myInfoHash != peerInfoHash) {
- throw new DlAbortEx("invalid handshake info hash: expected:%s, actual:%s",
- myInfoHash.c_str(), peerInfoHash.c_str());
- }
-}
-
void PeerMessageUtil::setIntParam(unsigned char* dest, uint32_t param) {
uint32_t nParam = htonl(param);
memcpy(dest, &nParam, sizeof(uint32_t));
diff --git a/src/PeerMessageUtil.h b/src/PeerMessageUtil.h
index aac462d3..a4fad679 100644
--- a/src/PeerMessageUtil.h
+++ b/src/PeerMessageUtil.h
@@ -36,7 +36,6 @@
#define _D_PEER_MESSAGE_UTIL_H_
#include "common.h"
-#include "HandshakeMessage.h"
#define MAX_BLOCK_LENGTH (128*1024)
@@ -82,9 +81,6 @@ public:
checkBitfield((unsigned char*)bitfield, bitfieldLength, pieces);
}
- static void checkHandshake(const HandshakeMessage* message,
- const unsigned char* infoHash);
-
static void createPeerMessageString(unsigned char* msg,
uint32_t msgLength,
uint32_t payloadLength,
diff --git a/src/PieceMessage.cc b/src/PieceMessage.cc
deleted file mode 100644
index 0e55a92f..00000000
--- a/src/PieceMessage.cc
+++ /dev/null
@@ -1,281 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "PieceMessage.h"
-#include "PeerMessageUtil.h"
-#include "PeerInteraction.h"
-#include "Util.h"
-#include "message.h"
-#include "DlAbortEx.h"
-
-void PieceMessage::setBlock(const char* block, int blockLength) {
- if(this->block != NULL) {
- delete [] this->block;
- }
- this->blockLength = blockLength;
- this->block = new char[this->blockLength];
- memcpy(this->block, block, this->blockLength);
-}
-
-PieceMessage* PieceMessage::create(const char* data, int dataLength) {
- if(dataLength <= 9) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be greater than %d", "piece", dataLength, 9);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "piece", ID);
- }
- PieceMessage* pieceMessage = new PieceMessage();
- pieceMessage->setIndex(PeerMessageUtil::getIntParam(data, 1));
- pieceMessage->setBegin(PeerMessageUtil::getIntParam(data, 5));
- pieceMessage->setBlock(data+9, dataLength-9);
- return pieceMessage;
-}
-
-void PieceMessage::receivedAction() {
- RequestSlot slot = peerInteraction->getCorrespondingRequestSlot(index,
- begin,
- blockLength);
- peer->updateDownloadLength(blockLength);
- if(!RequestSlot::isNull(slot) &&
- peerInteraction->hasDownloadPiece(slot.getIndex())) {
- peer->snubbing = false;
- //logger->debug("CUID#%d - Latency=%d", cuid, slot.getLatencyInMillis());
- peer->updateLatency(slot.getLatencyInMillis());
- PieceHandle piece = peerInteraction->getDownloadPiece(slot.getIndex());
- long long int offset =
- ((long long int)index)*btContext->getPieceLength()+begin;
- logger->debug("CUID#%d - Writing the block length=%d, offset=%lld",
- cuid, blockLength, offset);
- pieceStorage->getDiskAdaptor()->writeData(block,
- blockLength,
- offset);
- piece->completeBlock(slot.getBlockIndex());
- peerInteraction->deleteRequestSlot(slot);
- //pieceStorage->updatePiece(piece);
- logger->debug("CUID#%d - Setting piece block index=%d",
- cuid, slot.getBlockIndex());
- if(piece->pieceComplete()) {
- if(checkPieceHash(piece)) {
- onGotNewPiece(piece);
- } else {
- onGotWrongPiece(piece);
- }
- }
- }
-}
-
-const char* PieceMessage::getMessageHeader() {
- if(!inProgress) {
- /**
- * len --- 9+blockLength, 4bytes
- * id --- 7, 1byte
- * index --- index, 4bytes
- * begin --- begin, 4bytes
- * total: 13bytes
- */
- PeerMessageUtil::createPeerMessageString(msgHeader, sizeof(msgHeader),
- 9+blockLength, ID);
- PeerMessageUtil::setIntParam(&msgHeader[5], index);
- PeerMessageUtil::setIntParam(&msgHeader[9], begin);
- }
- return msgHeader;
-}
-
-int PieceMessage::getMessageHeaderLength() {
- return sizeof(msgHeader);
-}
-
-void PieceMessage::send() {
- if(invalidate) {
- return;
- }
- PeerConnection* peerConnection = peerInteraction->getPeerConnection();
- if(!headerSent) {
- if(!inProgress) {
- logger->info(MSG_SEND_PEER_MESSAGE,
- cuid, peer->ipaddr.c_str(), peer->port,
- toString().c_str());
- getMessageHeader();
- leftDataLength = getMessageHeaderLength();
- inProgress = true;
- }
- int writtenLength
- = peerConnection->sendMessage(msgHeader+getMessageHeaderLength()-leftDataLength,
- leftDataLength);
- if(writtenLength == leftDataLength) {
- headerSent = true;
- leftDataLength = blockLength;
- } else {
- leftDataLength -= writtenLength;
- }
- }
- if(headerSent) {
- inProgress = false;
- long long int pieceDataOffset =
- ((long long int)index)*btContext->getPieceLength()+begin+blockLength-leftDataLength;
- int writtenLength =
- sendPieceData(pieceDataOffset, leftDataLength);
- peer->updateUploadLength(writtenLength);
- if(writtenLength != leftDataLength) {
- inProgress = true;
- }
- leftDataLength -= writtenLength;
- }
-}
-
-int PieceMessage::sendPieceData(long long int offset, int length) const {
- int BUF_SIZE = 256;
- char buf[BUF_SIZE];
- int iteration = length/BUF_SIZE;
- int writtenLength = 0;
- PeerConnection* peerConnection = peerInteraction->getPeerConnection();
- for(int i = 0; i < iteration; i++) {
- if(pieceStorage->getDiskAdaptor()->readData(buf, BUF_SIZE, offset+i*BUF_SIZE) < BUF_SIZE) {
- throw new DlAbortEx("Failed to read data from disk.");
- }
- int ws = peerConnection->sendMessage(buf, BUF_SIZE);
- writtenLength += ws;
- if(ws != BUF_SIZE) {
- //logger->debug("CUID#%d - %d bytes written", cuid, writtenLength);
- return writtenLength;
- }
- }
-
- int rem = length%BUF_SIZE;
- if(rem > 0) {
- if(pieceStorage->getDiskAdaptor()->readData(buf, rem, offset+iteration*BUF_SIZE) < rem) {
- throw new DlAbortEx("Failed to read data from disk.");
- }
- int ws = peerConnection->sendMessage(buf, rem);
- writtenLength += ws;
- }
- //logger->debug("CUID#%d - %d bytes written", cuid, writtenLength);
- return writtenLength;
-}
-
-void PieceMessage::check() const {
- PeerMessageUtil::checkIndex(index, pieces);
- PeerMessageUtil::checkBegin(begin, pieceLength);
-}
-
-string PieceMessage::toString() const {
- return "piece index="+Util::itos(index)+", begin="+Util::itos(begin)+
- ", length="+Util::itos(blockLength);
-}
-
-bool PieceMessage::checkPieceHash(const PieceHandle& piece) {
- long long int offset =
- ((long long int)piece->getIndex())*btContext->getPieceLength();
- return pieceStorage->getDiskAdaptor()->sha1Sum(offset, piece->getLength()) ==
- btContext->getPieceHash(piece->getIndex());
-}
-
-void PieceMessage::onGotNewPiece(const PieceHandle& piece) {
- logger->info(MSG_GOT_NEW_PIECE, cuid, piece->getIndex());
- pieceStorage->completePiece(piece);
- pieceStorage->advertisePiece(cuid, piece->getIndex());
-}
-
-void PieceMessage::onGotWrongPiece(const PieceHandle& piece) {
- logger->error(MSG_GOT_WRONG_PIECE, cuid, piece->getIndex());
- erasePieceOnDisk(piece);
- piece->clearAllBlock();
- //pieceStorage->updatePiece(piece);
- peerInteraction->abortPiece(piece);
-}
-
-void PieceMessage::erasePieceOnDisk(const PieceHandle& piece) {
- int BUFSIZE = 4096;
- char buf[BUFSIZE];
- memset(buf, 0, BUFSIZE);
- long long int offset =
- ((long long int)piece->getIndex())*btContext->getPieceLength();
- for(int i = 0; i < piece->getLength()/BUFSIZE; i++) {
- pieceStorage->getDiskAdaptor()->writeData(buf, BUFSIZE, offset);
- offset += BUFSIZE;
- }
- int r = piece->getLength()%BUFSIZE;
- if(r > 0) {
- pieceStorage->getDiskAdaptor()->writeData(buf, r, offset);
- }
-}
-
-PeerMessageHandle PieceMessage::createRejectMessage(int index,
- int begin,
- int blockLength) const {
- return peerInteraction->getPeerMessageFactory()->
- createRejectMessage(index,
- begin,
- blockLength);
-}
-
-void PieceMessage::onChoked() {
- if(!invalidate &&
- !inProgress &&
- !peerInteraction->isInFastSet(index)) {
- logger->debug("CUID#%d - Reject piece message in queue because"
- " the peer has been choked. index=%d, begin=%d, length=%d",
- cuid,
- index,
- begin,
- blockLength);
-
- if(peer->isFastExtensionEnabled()) {
- peerInteraction->addMessage(createRejectMessage(index,
- begin,
- blockLength));
- }
- invalidate = true;
- }
-}
-
-void PieceMessage::onCanceled(int index, int begin, int blockLength) {
- if(!invalidate &&
- !inProgress &&
- this->index == index &&
- this->begin == begin &&
- this->blockLength == blockLength) {
- logger->debug("CUID#%d - Reject piece message in queue because cancel"
- " message received. index=%d, begin=%d, length=%d",
- cuid, index, begin, blockLength);
- if(peer->isFastExtensionEnabled()) {
- peerInteraction->addMessage(createRejectMessage(index,
- begin,
- blockLength));
- }
- invalidate = true;
- }
-}
diff --git a/src/PieceMessage.h b/src/PieceMessage.h
deleted file mode 100644
index 48b5cac1..00000000
--- a/src/PieceMessage.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_PIECE_MESSAGE_H_
-#define _D_PIECE_MESSAGE_H_
-
-#include "PeerMessage.h"
-
-class PieceMessage : public PeerMessage {
-private:
- int index;
- int begin;
- char* block;
- int blockLength;
- int leftDataLength;
- bool headerSent;
- int pendingCount;
- // for check
- int pieces;
- int pieceLength;
-
- char msgHeader[13];
-
- bool checkPieceHash(const PieceHandle& piece);
- void onGotNewPiece(const PieceHandle& piece);
- void onGotWrongPiece(const PieceHandle& piece);
- void erasePieceOnDisk(const PieceHandle& piece);
- int sendPieceData(long long int offset, int length) const;
- PeerMessageHandle createRejectMessage(int index, int begin, int blockLength) const;
-public:
- PieceMessage(int index = 0, int begin = 0, int blockLength = 0)
- :PeerMessage(),
- index(index),
- begin(begin),
- block(0),
- blockLength(blockLength),
- leftDataLength(0),
- headerSent(false),
- pendingCount(0),
- pieces(0),
- pieceLength(0)
- {
- uploading = true;
- }
-
- virtual ~PieceMessage() {
- delete [] block;
- }
-
- enum ID_t {
- ID = 7
- };
-
- int getIndex() const { return index; }
- void setIndex(int index) { this->index = index; }
- int getBegin() const { return begin; }
- void setBegin(int begin) { this->begin = begin; }
- const char* getBlock() const { return block; }
- void setBlock(const char* block, int blockLength);
- int getBlockLength() const { return blockLength; }
- void setBlockLength(int blockLength) { this->blockLength = blockLength; }
-
- void setPieces(int pieces) {
- this->pieces = pieces;
- }
- int getPieces() const { return pieces;}
-
- void setPieceLength(int pieceLength) {
- this->pieceLength = pieceLength;
- }
- int getPieceLength() const { return pieceLength;}
-
- void incrementPendingCount() { pendingCount++; }
- bool isPendingCountMax() const { return pendingCount > 2; }
-
- static PieceMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessageHeader();
- virtual int getMessageHeaderLength();
- virtual void send();
- virtual void check() const;
- virtual string toString() const;
- virtual void onChoked();
- virtual void onCanceled(int index, int begin, int blockLength);
-};
-
-#endif // _D_PIECE_MESSAGE_H_
diff --git a/src/PortMessage.cc b/src/PortMessage.cc
deleted file mode 100644
index 1bdbb54e..00000000
--- a/src/PortMessage.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "PortMessage.h"
-#include "PeerMessageUtil.h"
-#include "DlAbortEx.h"
-
-PortMessage* PortMessage::create(const char* data, int dataLength) {
- if(dataLength != 3) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "port", dataLength, 3);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "piece", ID);
- }
- PortMessage* portMessage = new PortMessage();
- portMessage->setPort(PeerMessageUtil::getShortIntParam(data, 1));
- return portMessage;
-}
diff --git a/src/PortMessage.h b/src/PortMessage.h
deleted file mode 100644
index 525c66a0..00000000
--- a/src/PortMessage.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_PORT_MESSAGE_H_
-#define _D_PORT_MESSAGE_H_
-
-#include "PeerMessage.h"
-
-class PortMessage : public PeerMessage {
-private:
- int port;
-public:
- PortMessage():PeerMessage() {}
- virtual ~PortMessage() {}
-
- enum ID_t {
- ID = 9
- };
-
- int getPort() const { return port; }
- void setPort(int port) { this->port = port; }
-
- virtual int getId() const { return ID; }
-
- static PortMessage* create(const char* data, int dataLength);
-
- virtual void receivedAction() {
- logger->info("DHT is not supported yet.");
- }
- virtual void send() {}
- virtual string toString() const {
- return "port";
- }
-};
-
-#endif // _D_PORT_MESSAGE_H_
diff --git a/src/RejectMessage.cc b/src/RejectMessage.cc
deleted file mode 100644
index 84d55bf9..00000000
--- a/src/RejectMessage.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "RejectMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "Util.h"
-#include "DlAbortEx.h"
-
-RejectMessage* RejectMessage::create(const char* data, int dataLength) {
- if(dataLength != 13) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "reject", dataLength, 13);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "reject", ID);
- }
- RejectMessage* rejectMessage = new RejectMessage();
- rejectMessage->setIndex(PeerMessageUtil::getIntParam(data, 1));
- rejectMessage->setBegin(PeerMessageUtil::getIntParam(data, 5));
- rejectMessage->setLength(PeerMessageUtil::getIntParam(data, 9));
- return rejectMessage;
-}
-
-void RejectMessage::receivedAction() {
- if(!peer->isFastExtensionEnabled()) {
- throw new DlAbortEx("%s received while fast extension is disabled",
- toString().c_str());
- }
- // TODO Current implementation does not close a connection even if
- // a request for this reject message is never sent.
- RequestSlot slot =
- peerInteraction->getCorrespondingRequestSlot(index, begin, length);
- if(RequestSlot::isNull(slot)) {
- //throw new DlAbortEx("reject recieved, but it is not in the request slots.");
- } else {
- peerInteraction->deleteRequestSlot(slot);
- }
-
-}
-
-const char* RejectMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 13, 4bytes
- * id --- 16, 1byte
- * index --- index, 4bytes
- * begin --- begin, 4bytes
- * length -- length, 4bytes
- * total: 17bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 13, ID);
- PeerMessageUtil::setIntParam(&msg[5], index);
- PeerMessageUtil::setIntParam(&msg[9], begin);
- PeerMessageUtil::setIntParam(&msg[13], length);
- }
- return msg;
-}
-
-int RejectMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void RejectMessage::check() const {
- PeerMessageUtil::checkIndex(index, pieces);
- PeerMessageUtil::checkBegin(begin, pieceLength);
- PeerMessageUtil::checkLength(length);
- PeerMessageUtil::checkRange(begin, length, pieceLength);
-}
-
-string RejectMessage::toString() const {
- return "reject index="+Util::itos(index)+", begin="+Util::itos(begin)+
- ", length="+Util::itos(length);
-}
diff --git a/src/RejectMessage.h b/src/RejectMessage.h
deleted file mode 100644
index 5b33d37e..00000000
--- a/src/RejectMessage.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_REJECT_MESSAGE_H_
-#define _D_REJECT_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class RejectMessage : public SimplePeerMessage {
-private:
- int index;
- int begin;
- int length;
- // for check
- int pieces;
- int pieceLength;
-
- char msg[17];
-public:
- RejectMessage(int index = 0, int begin = 0, int length = 0)
- :SimplePeerMessage(),
- index(index),
- begin(begin),
- length(length),
- pieces(0),
- pieceLength(0) {}
-
- virtual ~RejectMessage() {}
-
- enum ID_t {
- ID = 16
- };
-
- int getIndex() const { return index; }
- void setIndex(int index) { this->index = index; }
- int getBegin() const { return begin; }
- void setBegin(int begin) { this->begin = begin; }
- int getLength() const { return length; }
- void setLength(int length) { this->length = length; }
-
- void setPieces(int pieces) {
- this->pieces = pieces;
- }
- int getPieces() const { return pieces;}
-
- void setPieceLength(int pieceLength) {
- this->pieceLength = pieceLength;
- }
- int getPieceLength() const { return pieceLength;}
-
- static RejectMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual void check() const;
- virtual string toString() const;
-};
-
-#endif // _D_REJECT_MESSAGE_H_
diff --git a/src/RequestMessage.cc b/src/RequestMessage.cc
deleted file mode 100644
index 0ab6e343..00000000
--- a/src/RequestMessage.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "RequestMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "Util.h"
-#include "DlAbortEx.h"
-
-RequestMessage* RequestMessage::create(const char* data, int dataLength) {
- if(dataLength != 13) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "request", dataLength, 13);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "request", ID);
- }
- RequestMessage* requestMessage = new RequestMessage();
- requestMessage->setIndex(PeerMessageUtil::getIntParam(data, 1));
- requestMessage->setBegin(PeerMessageUtil::getIntParam(data, 5));
- requestMessage->setLength(PeerMessageUtil::getIntParam(data, 9));
- return requestMessage;
-}
-
-void RequestMessage::receivedAction() {
- if(pieceStorage->hasPiece(index) &&
- (!peer->amChoking ||
- peer->amChoking && peerInteraction->isInFastSet(index))) {
- peerInteraction->addMessage(peerInteraction->getPeerMessageFactory()->
- createPieceMessage(index, begin, length));
- } else {
- if(peer->isFastExtensionEnabled()) {
- peerInteraction->addMessage(peerInteraction->getPeerMessageFactory()->
- createRejectMessage(index, begin, length));
- }
- }
-}
-
-const char* RequestMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 13, 4bytes
- * id --- 6, 1byte
- * index --- index, 4bytes
- * begin --- begin, 4bytes
- * length --- length, 4bytes
- * total: 17bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 13, ID);
- PeerMessageUtil::setIntParam(&msg[5], index);
- PeerMessageUtil::setIntParam(&msg[9], begin);
- PeerMessageUtil::setIntParam(&msg[13], length);
- }
- return msg;
-}
-
-int RequestMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void RequestMessage::check() const {
- PeerMessageUtil::checkIndex(index, pieces);
- PeerMessageUtil::checkBegin(begin, pieceLength);
- PeerMessageUtil::checkLength(length);
- PeerMessageUtil::checkRange(begin, length, pieceLength);
-}
-
-string RequestMessage::toString() const {
- return "request index="+Util::itos(index)+", begin="+Util::itos(begin)+
- ", length="+Util::itos(length);
-}
-
-void RequestMessage::onPush() {
- RequestSlot requestSlot(index, begin, length, blockIndex);
- peerInteraction->addRequestSlot(requestSlot);
-}
-
-void RequestMessage::onAbortPiece(const Piece& piece) {
- if(!invalidate &&
- !inProgress &&
- this->index == piece.getIndex()) {
- invalidate = true;
- }
-}
diff --git a/src/RequestMessage.h b/src/RequestMessage.h
deleted file mode 100644
index 7c7c7b20..00000000
--- a/src/RequestMessage.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_REQUEST_MESSAGE_H_
-#define _D_REQUEST_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class RequestMessage : public SimplePeerMessage {
-private:
- int index;
- int begin;
- int length;
- int blockIndex;
- // for check
- int pieces;
- int pieceLength;
-
- char msg[17];
-public:
- RequestMessage(int index = 0, int begin = 0, int length = 0,
- int blockIndex = 0)
- :SimplePeerMessage(),
- index(index),
- begin(begin),
- length(length),
- blockIndex(blockIndex),
- pieces(0),
- pieceLength(0) {}
-
- virtual ~RequestMessage() {}
-
- enum ID_t {
- ID = 6
- };
-
- int getIndex() const { return index; }
- void setIndex(int index) { this->index = index; }
- int getBegin() const { return begin; }
- void setBegin(int begin) { this->begin = begin; }
- int getLength() const { return length; }
- void setLength(int length) { this->length = length; }
- int getBlockIndex() const { return blockIndex; }
- void setBlockIndex(int blockIndex) { this->blockIndex = blockIndex; }
-
- void setPieces(int pieces) {
- this->pieces = pieces;
- }
- int getPieces() const { return pieces;}
-
- void setPieceLength(int pieceLength) {
- this->pieceLength = pieceLength;
- }
- int getPieceLength() const { return pieceLength;}
-
- static RequestMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual void check() const;
- virtual string toString() const;
- virtual void onPush();
- virtual void onAbortPiece(const Piece& piece);
-};
-
-#endif // _D_REQUEST_MESSAGE_H_
diff --git a/src/SimplePeerMessage.cc b/src/SimplePeerMessage.cc
deleted file mode 100644
index 3e59b477..00000000
--- a/src/SimplePeerMessage.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "SimplePeerMessage.h"
-#include "message.h"
-#include "PeerInteraction.h"
-
-SimplePeerMessage::SimplePeerMessage():leftDataLength(0) {}
-
-SimplePeerMessage::~SimplePeerMessage() {}
-
-void SimplePeerMessage::send() {
- if(invalidate) {
- return;
- }
- if(sendPredicate() || inProgress) {
- const char* msg = getMessage();
- int msgLength = getMessageLength();
- if(!inProgress) {
- logger->info(MSG_SEND_PEER_MESSAGE,
- cuid, peer->ipaddr.c_str(), peer->port, toString().c_str());
- leftDataLength = getMessageLength();
- }
- inProgress = false;
- int writtenLength = peerInteraction->getPeerConnection()->sendMessage(msg+msgLength-leftDataLength, leftDataLength);
- if(writtenLength == leftDataLength) {
- onSendComplete();
- } else {
- leftDataLength -= writtenLength;
- inProgress = true;
- }
- }
-}
diff --git a/src/SimplePeerMessage.h b/src/SimplePeerMessage.h
deleted file mode 100644
index a608ba07..00000000
--- a/src/SimplePeerMessage.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_SIMPLE_PEER_MESSAGE_H_
-#define _D_SIMPLE_PEER_MESSAGE_H_
-
-#include "PeerMessage.h"
-
-class SimplePeerMessage : public PeerMessage {
-private:
- int leftDataLength;
-protected:
- virtual bool sendPredicate() const { return true; };
- virtual void onSendComplete() {};
-public:
- SimplePeerMessage();
- virtual ~SimplePeerMessage();
-
- virtual void send();
- virtual const char* getMessage() = 0;
- virtual int getMessageLength() = 0;
-};
-
-#endif // _D_SIMPLE_PEER_MESSAGE_H_
diff --git a/src/SuggestPieceMessage.cc b/src/SuggestPieceMessage.cc
deleted file mode 100644
index 3303ced7..00000000
--- a/src/SuggestPieceMessage.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "SuggestPieceMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "Util.h"
-#include "DlAbortEx.h"
-
-SuggestPieceMessage* SuggestPieceMessage::create(const char* data, int dataLength) {
- if(dataLength != 5) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "suggest piece", dataLength, 5);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "suggest piece", ID);
- }
- SuggestPieceMessage* suggestPieceMessage = new SuggestPieceMessage();
- suggestPieceMessage->setIndex(PeerMessageUtil::getIntParam(data, 1));
- return suggestPieceMessage;
-}
-
-void SuggestPieceMessage::receivedAction() {
- // TODO Current implementation ignores this message.
-}
-
-const char* SuggestPieceMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 5, 4bytes
- * id --- 13, 1byte
- * piece index --- index, 4bytes
- * total: 9bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, ID);
- PeerMessageUtil::setIntParam(&msg[5], index);
- }
- return msg;
-}
-
-int SuggestPieceMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void SuggestPieceMessage::check() const {
- PeerMessageUtil::checkIndex(index, pieces);
-}
-
-string SuggestPieceMessage::toString() const {
- return "suggest piece index="+Util::itos(index);
-}
diff --git a/src/SuggestPieceMessage.h b/src/SuggestPieceMessage.h
deleted file mode 100644
index 0380c591..00000000
--- a/src/SuggestPieceMessage.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_SUGGEST_PIECE_MESSAGE_H_
-#define _D_SUGGEST_PIECE_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class SuggestPieceMessage : public SimplePeerMessage {
-private:
- int index;
- // for check
- int pieces;
- char msg[9];
-public:
- SuggestPieceMessage():SimplePeerMessage(), index(0), pieces(0) {}
-
- virtual ~SuggestPieceMessage() {}
-
- enum ID_t {
- ID = 13
- };
-
- void setIndex(int index) {
- this->index = index;
- }
- int getIndex() const { return index; }
-
- void setPieces(int pieces) {
- this->pieces = pieces;
- }
- int getPieces() const { return pieces;}
-
- static SuggestPieceMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual void check() const;
- virtual string toString() const;
-};
-
-#endif // _D_SUGGEST_PIECE_MESSAGE_H_
diff --git a/src/UnchokeMessage.cc b/src/UnchokeMessage.cc
deleted file mode 100644
index 51b2b8d3..00000000
--- a/src/UnchokeMessage.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#include "UnchokeMessage.h"
-#include "PeerInteraction.h"
-#include "PeerMessageUtil.h"
-#include "DlAbortEx.h"
-
-UnchokeMessage* UnchokeMessage::create(const char* data, int dataLength) {
- if(dataLength != 1) {
- throw new DlAbortEx("invalid payload size for %s, size = %d. It should be %d", "unchoke", dataLength, 1);
- }
- int id = PeerMessageUtil::getId(data);
- if(id != ID) {
- throw new DlAbortEx("invalid ID=%d for %s. It should be %d.",
- id, "unchoke", ID);
- }
- UnchokeMessage* unchokeMessage = new UnchokeMessage();
- return unchokeMessage;
-}
-
-void UnchokeMessage::receivedAction() {
- peer->peerChoking = false;
-}
-
-bool UnchokeMessage::sendPredicate() const {
- return peer->amChoking;
-}
-
-const char* UnchokeMessage::getMessage() {
- if(!inProgress) {
- /**
- * len --- 1, 4bytes
- * id --- 1, 1byte
- * total: 5bytes
- */
- PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, ID);
- }
- return msg;
-}
-
-int UnchokeMessage::getMessageLength() {
- return sizeof(msg);
-}
-
-void UnchokeMessage::onSendComplete() {
- peer->amChoking = false;
-}
-
-string UnchokeMessage::toString() const {
- return "unchoke";
-}
diff --git a/src/UnchokeMessage.h b/src/UnchokeMessage.h
deleted file mode 100644
index 3abf252c..00000000
--- a/src/UnchokeMessage.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 Tatsuhiro Tsujikawa
- *
- * 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_UNCHOKE_MESSAGE_H_
-#define _D_UNCHOKE_MESSAGE_H_
-
-#include "SimplePeerMessage.h"
-
-class UnchokeMessage : public SimplePeerMessage {
-private:
- char msg[5];
-protected:
- virtual bool sendPredicate() const;
- virtual void onSendComplete();
-public:
- UnchokeMessage():SimplePeerMessage() {}
- virtual ~UnchokeMessage() {}
-
- enum ID_t {
- ID = 1
- };
-
- static UnchokeMessage* create(const char* data, int dataLength);
-
- virtual int getId() const { return ID; }
- virtual void receivedAction();
- virtual const char* getMessage();
- virtual int getMessageLength();
- virtual string toString() const;
-};
-
-#endif // _D_UNCHOKE_MESSAGE_H_