diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-08-07 14:15:21 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-08-07 14:15:21 +0000 |
| commit | 26d66923767581d63fdfc303525cddebf9125bde (patch) | |
| tree | 97eb6054d697b53c7296adfaeaa43fb8013de3f2 /src/DHTRoutingTableDeserializer.cc | |
| parent | be7012272dbd029a7843df43466f4cd83e6fb9e3 (diff) | |
2010-08-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added IPv6 DHT. Added --dht-entry-porint6, --dht-file-path6,
--dht-listen-addr6 and --enable-dht6 option. IPv6 DHT is disabled
by default. To use IPv6 DHT, you need to use --enable-dht6 and
specify a global unicast address to --dht-listen-addr6. IPv6 DHT
is highly experimental.
* src/BtSetup.cc
* src/DHTAutoSaveCommand.cc
* src/DHTAutoSaveCommand.h
* src/DHTConnectionImpl.cc
* src/DHTConnectionImpl.h
* src/DHTEntryPointNameResolveCommand.cc
* src/DHTFindNodeReplyMessage.cc
* src/DHTFindNodeReplyMessage.h
* src/DHTGetPeersMessage.cc
* src/DHTGetPeersReplyMessage.cc
* src/DHTGetPeersReplyMessage.h
* src/DHTMessageFactory.h
* src/DHTMessageFactoryImpl.cc
* src/DHTMessageFactoryImpl.h
* src/DHTMessageTracker.cc
* src/DHTRegistry.cc
* src/DHTRegistry.h
* src/DHTRoutingTableDeserializer.cc
* src/DHTRoutingTableDeserializer.h
* src/DHTRoutingTableSerializer.cc
* src/DHTRoutingTableSerializer.h
* src/DHTSetup.cc
* src/DHTSetup.h
* src/FtpConnection.cc
* src/LpdMessageReceiver.cc
* src/OptionHandlerFactory.cc
* src/OptionHandlerImpl.h
* src/PeerInteractionCommand.cc
* src/RequestGroup.cc
* src/SocketCore.cc
* src/SocketCore.h
* src/bittorrent_helper.cc
* src/bittorrent_helper.h
* src/prefs.cc
* src/prefs.h
* src/usage_text.h
* test/DHTConnectionImplTest.cc
* test/DHTFindNodeReplyMessageTest.cc
* test/DHTGetPeersMessageTest.cc
* test/DHTGetPeersReplyMessageTest.cc
* test/DHTMessageFactoryImplTest.cc
* test/DHTRoutingTableDeserializerTest.cc
* test/DHTRoutingTableSerializerTest.cc
* test/LpdMessageDispatcherTest.cc
* test/MockDHTMessageFactory.h
Diffstat (limited to 'src/DHTRoutingTableDeserializer.cc')
| -rw-r--r-- | src/DHTRoutingTableDeserializer.cc | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/DHTRoutingTableDeserializer.cc b/src/DHTRoutingTableDeserializer.cc index bed629ca..d06de4b3 100644 --- a/src/DHTRoutingTableDeserializer.cc +++ b/src/DHTRoutingTableDeserializer.cc @@ -52,7 +52,8 @@ namespace aria2 { -DHTRoutingTableDeserializer::DHTRoutingTableDeserializer() {} +DHTRoutingTableDeserializer::DHTRoutingTableDeserializer(int family): + family_(family) {} DHTRoutingTableDeserializer::~DHTRoutingTableDeserializer() {} @@ -99,7 +100,7 @@ void DHTRoutingTableDeserializer::deserialize(std::istream& in) headerCompat[6] = 0; headerCompat[7] = 0x02; - char zero[8]; + char zero[18]; memset(zero, 0, sizeof(zero)); int version; @@ -159,44 +160,39 @@ void DHTRoutingTableDeserializer::deserialize(std::istream& in) std::vector<SharedHandle<DHTNode> > nodes; // nodes + const int compactlen = bittorrent::getCompactLength(family_); for(size_t i = 0; i < numNodes; ++i) { - // Currently, only IPv4 addresses are supported. // 1byte compact peer info length uint8_t peerInfoLen; in >> peerInfoLen; - if(peerInfoLen != 6) { + if(peerInfoLen != compactlen) { // skip this entry - readBytes(buf, buf.size(), in, 42+7+6); - CHECK_STREAM(in, 42+7+6); + readBytes(buf, buf.size(), in, 7+48); + CHECK_STREAM(in, 7+48); continue; } // 7bytes reserved readBytes(buf, buf.size(), in, 7); CHECK_STREAM(in, 7); - // 6bytes compact peer info - readBytes(buf, buf.size(), in, 6); - CHECK_STREAM(in, 6); - if(memcmp(zero, buf, 6) == 0) { + // compactlen bytes compact peer info + readBytes(buf, buf.size(), in, compactlen); + CHECK_STREAM(in, compactlen); + if(memcmp(zero, buf, compactlen) == 0) { // skip this entry - readBytes(buf, buf.size(), in, 42); - CHECK_STREAM(in, 42); + readBytes(buf, buf.size(), in, 48-compactlen); + CHECK_STREAM(in, 48-compactlen); continue; } - // TODO DHT6 protocol family should be configurable. std::pair<std::string, uint16_t> peer = - bittorrent::unpackcompact(buf, AF_INET); + bittorrent::unpackcompact(buf, family_); if(peer.first.empty()) { // skip this entry - readBytes(buf, buf.size(), in, 42); - CHECK_STREAM(in, 42); + readBytes(buf, buf.size(), in, 48-compactlen); + CHECK_STREAM(in, 48-compactlen); continue; } - // 2bytes reserved - readBytes(buf, buf.size(), in, 2); - CHECK_STREAM(in, 2); - // 16byte reserved - readBytes(buf, buf.size(), in, 16); - CHECK_STREAM(in, 16); + // 24-compactlen bytes reserved + readBytes(buf, buf.size(), in, 24-compactlen); // node ID readBytes(buf, buf.size(), in, DHT_ID_LENGTH); CHECK_STREAM(in, DHT_ID_LENGTH); |
