Ejemplo n.º 1
0
	void NetDb::HandleDatabaseStoreMsg (uint8_t * buf, size_t len)
	{		
		I2NPDatabaseStoreMsg * msg = (I2NPDatabaseStoreMsg *)buf;
		size_t offset = sizeof (I2NPDatabaseStoreMsg);
		if (msg->replyToken)
			offset += 36;
		if (msg->type)
		{
			LogPrint ("LeaseSet");
			AddLeaseSet (buf + offset, len - offset);
		}	
		else
		{
			LogPrint ("RouterInfo");
			size_t size = be16toh (*(uint16_t *)(buf + offset));
			if (size > 2048)
			{
				LogPrint ("Invalid RouterInfo length ", (int)size);
				return;
			}	
			offset += 2;
			CryptoPP::Gunzip decompressor;
			decompressor.Put (buf + offset, size);
			decompressor.MessageEnd();
			uint8_t uncompressed[2048];
			int uncomressedSize = decompressor.MaxRetrievable ();
			decompressor.Get (uncompressed, uncomressedSize);
			AddRouterInfo (uncompressed, uncomressedSize);
		}	
	}	
Ejemplo n.º 2
0
 Data Gzip::Decompress(const void *data, size_t size) {
     //TODO Change interface to taking cpputils::Data objects (needs changing blockstore so we can read their "class Data", because this is called from CompressedBlock::Decompress()).
     CryptoPP::Gunzip zipper;
     zipper.Put((byte *) data, size);
     zipper.MessageEnd();
     Data decompressed(zipper.MaxRetrievable());
     zipper.Get((byte *) decompressed.data(), decompressed.size());
     return decompressed;
 }
Ejemplo n.º 3
0
	void DatagramDestination::HandleDataMessagePayload (uint16_t fromPort, uint16_t toPort, 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);
			HandleDatagram (fromPort, toPort, uncompressed, uncompressedLen); 
		}
		else
			LogPrint ("Received datagram size ", uncompressedLen,  " exceeds max size");

	}