2010-08-03 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added bittorrent::packcompact() which replaces
	bittorrent::createcompact() and supports IPv6 addresses. Rewritten
	bittorrent::unpackcompact() and bittorrent::extractPeer() to
	support IPv6 addresses. Fixed added.f flags in ut_pex.
	* src/BtConstants.h
	* src/DHTFindNodeReplyMessage.cc
	* src/DHTGetPeersReplyMessage.cc
	* src/DHTMessageFactoryImpl.cc
	* src/DHTRoutingTableDeserializer.cc
	* src/DHTRoutingTableSerializer.cc
	* src/DHTTokenTracker.cc
	* src/DefaultBtAnnounce.cc
	* src/UTPexExtensionMessage.cc
	* src/bittorrent_helper.cc
	* src/bittorrent_helper.h
	* test/BittorrentHelperTest.cc
	* test/DHTFindNodeReplyMessageTest.cc
	* test/DHTGetPeersReplyMessageTest.cc
	* test/DHTMessageFactoryImplTest.cc
	* test/DHTRoutingTableSerializerTest.cc
	* test/DefaultExtensionMessageFactoryTest.cc
	* test/UTPexExtensionMessageTest.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2010-08-03 11:44:24 +00:00
parent 939a372727
commit 2bd5020f81
19 changed files with 275 additions and 162 deletions

View file

@ -57,12 +57,12 @@ void DHTGetPeersReplyMessageTest::testGetBencodedMessage()
nodes[i]->setIPAddress("192.168.0."+util::uitos(i+1));
nodes[i]->setPort(6881+i);
unsigned char buf[6];
CPPUNIT_ASSERT(bittorrent::createcompact
(buf, nodes[i]->getIPAddress(), nodes[i]->getPort()));
unsigned char buf[COMPACT_LEN_IPV6];
bittorrent::packcompact
(buf, nodes[i]->getIPAddress(), nodes[i]->getPort());
compactNodeInfo +=
std::string(&nodes[i]->getID()[0], &nodes[i]->getID()[DHT_ID_LENGTH])+
std::string(&buf[0], &buf[sizeof(buf)]);
std::string(&buf[0], &buf[COMPACT_LEN_IPV4]);
}
msg.setClosestKNodes
(std::vector<SharedHandle<DHTNode> >(&nodes[0], &nodes[DHTBucket::K]));
@ -80,10 +80,9 @@ void DHTGetPeersReplyMessageTest::testGetBencodedMessage()
SharedHandle<List> valuesList = List::g();
for(size_t i = 0; i < 4; ++i) {
SharedHandle<Peer> peer(new Peer("192.168.0."+util::uitos(i+1), 6881+i));
unsigned char buffer[6];
CPPUNIT_ASSERT(bittorrent::createcompact
(buffer, peer->getIPAddress(), peer->getPort()));
valuesList->append(String::g(buffer, sizeof(buffer)));
unsigned char buffer[COMPACT_LEN_IPV6];
bittorrent::packcompact(buffer, peer->getIPAddress(), peer->getPort());
valuesList->append(String::g(buffer, COMPACT_LEN_IPV4));
peers.push_back(peer);
}
rDict->put("values", valuesList);