mirror of https://github.com/PurpleI2P/i2pd.git
orignal
10 years ago
8 changed files with 89 additions and 8 deletions
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
#include <cryptopp/gzip.h> |
||||
#include "Log.h" |
||||
#include "Datagram.h" |
||||
|
||||
namespace i2p |
||||
{ |
||||
namespace datagram |
||||
{ |
||||
void DatagramDestination::HandleDataMessagePayload (const uint8_t * buf, size_t len) |
||||
{ |
||||
// unzip it
|
||||
CryptoPP::Gunzip decompressor; |
||||
decompressor.Put (buf, len); |
||||
decompressor.MessageEnd(); |
||||
uint8_t uncompressed[MAX_DATAGRAM_SIZE]; |
||||
auto uncompressedLen = decompressor.MaxRetrievable (); |
||||
if (uncompressedLen <= MAX_DATAGRAM_SIZE) |
||||
{ |
||||
decompressor.Get (uncompressed, uncompressedLen); |
||||
//HandleNextPacket (uncompressed);
|
||||
} |
||||
else |
||||
LogPrint ("Received datagram size ", uncompressedLen, " exceeds max size"); |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
||||
|
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
#ifndef DATAGRAM_H__ |
||||
#define DATAGRAM_H__ |
||||
|
||||
#include <inttypes.h> |
||||
|
||||
namespace i2p |
||||
{ |
||||
namespace client |
||||
{ |
||||
class ClientDestination; |
||||
} |
||||
namespace datagram |
||||
{ |
||||
const size_t MAX_DATAGRAM_SIZE = 32768; |
||||
class DatagramDestination |
||||
{ |
||||
public: |
||||
|
||||
DatagramDestination (i2p::client::ClientDestination& owner): m_Owner (owner) {}; |
||||
~DatagramDestination () {}; |
||||
|
||||
void HandleDataMessagePayload (const uint8_t * buf, size_t len); |
||||
|
||||
private: |
||||
|
||||
i2p::client::ClientDestination& m_Owner; |
||||
}; |
||||
} |
||||
} |
||||
|
||||
#endif |
||||
|
Loading…
Reference in new issue