packets.cpp File Reference

Implementation of Packet objects input/output. More...

#include <hn/hnprec.h>
#include <hn/osdep.h>
#include <hn/partdata.h>
#include <boost/tuple/tuple.hpp>
#include <boost/random/mersenne_twister.hpp>
#include "packets.h"
#include "ed2k.h"
#include "serverlist.h"
#include "tag.h"
#include "ed2kfile.h"
#include "zutils.h"
#include <bitset>

Go to the source code of this file.


Namespaces

namespace  ED2KPacket

Functions

uint64_t getOverheadUp ()
uint64_t getOverheadDn ()
void addOverheadDn (uint32_t amount)
std::vector< bool > makePartMap (const PartData *pd)
 Generates chunk map, as specified by eDonkey2000 protocol.
void writePartMap (std::ostream &o, const std::vector< bool > &partMap)
void readPartMap (std::istream &i, std::vector< bool > *partMap)

Variables

boost::mt19937 getRandom
uint64_t s_overheadUpSize = 0
uint64_t s_overheadDnSize = 0

Detailed Description

Implementation of Packet objects input/output.

This file basically includes the entire eDonkey2000 protocol packets reading writing. As such, this file grows rather big over time. In addition to that, this file also needs to include large amount of ed2k module headers, since we want the packet objects to be as self-contained as possible, requiring minimum amount of construction arguments for easier usage. If this file grows beyond our management capabilities, it could be broken up into several smaller files, based on some criteria.

Definition in file packets.cpp.


Function Documentation

uint64_t ED2KPacket::getOverheadUp  ) 
 

Definition at line 55 of file packets.cpp.

References ED2KPacket::s_overheadUpSize.

Referenced by ClientList::checkOpenMoreSlots().

uint64_t ED2KPacket::getOverheadDn  ) 
 

Definition at line 56 of file packets.cpp.

References ED2KPacket::s_overheadDnSize.

Referenced by ClientList::checkOpenMoreSlots().

void ED2KPacket::addOverheadDn uint32_t  amount  ) 
 

Definition at line 57 of file packets.cpp.

References ED2KPacket::s_overheadDnSize.

Referenced by ED2KParser< Parent >::readPacket().

std::vector<bool> makePartMap const PartData *  pd  ) 
 

Generates chunk map, as specified by eDonkey2000 protocol.

This means the vector is filled with bitfields, where each 'true' bit indicates we have the 9.28MB part, and each 'false' bit indicates we do not have that part. Empty partmap indicates the entire file is available. Leftover bits are padded with zeros.

Note that PartData API now supports this internally, so when possible, we attempt to aquire this data from PartData. However, if that fails, we still generate it ourselves here.

Definition at line 70 of file packets.cpp.

Referenced by ED2KPacket::FileStatus::FileStatus(), ED2KPacket::ReaskAck::ReaskAck(), ED2KPacket::ReaskFilePing::ReaskFilePing(), and ED2KPacket::ReqFile::ReqFile().

void writePartMap std::ostream &  o,
const std::vector< bool > &  partMap
 

Definition at line 90 of file packets.cpp.

Referenced by ED2KPacket::ReaskAck::operator std::string(), ED2KPacket::ReaskFilePing::operator std::string(), ED2KPacket::FileStatus::operator std::string(), and ED2KPacket::ReqFile::operator std::string().

void readPartMap std::istream &  i,
std::vector< bool > *  partMap
 

Definition at line 108 of file packets.cpp.

Referenced by ED2KPacket::FileStatus::FileStatus(), ED2KPacket::ReaskAck::ReaskAck(), ED2KPacket::ReaskFilePing::ReaskFilePing(), and ED2KPacket::ReqFile::ReqFile().


Variable Documentation

boost::mt19937 ED2KPacket::getRandom
 

Definition at line 51 of file packets.cpp.

Referenced by ED2KPacket::GlobStatReq::GlobStatReq(), and ED2KPacket::SecIdentState::SecIdentState().

uint64_t ED2KPacket::s_overheadUpSize = 0
 

Definition at line 53 of file packets.cpp.

Referenced by ED2KPacket::getOverheadUp(), and ED2KPacket::Packet::makePacket().

uint64_t ED2KPacket::s_overheadDnSize = 0
 

Definition at line 54 of file packets.cpp.

Referenced by ED2KPacket::addOverheadDn(), and ED2KPacket::getOverheadDn().