mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-19 18:42:36 -05:00
Major improvements to the serialiser to make it work with retroshare.
This is still a first draft - the message types will surely change. -corrected ids and added service classes. -Added disc/msg/chat/cache/file messages -Extended serialiser to handle service extensions. -corrected IpAddrPort code. -More debugging code. -Added some tests. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@270 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9f76b1a313
commit
e8ccb0b427
22 changed files with 3101 additions and 333 deletions
|
|
@ -28,8 +28,13 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rstlvtypes.h"
|
||||
|
||||
const uint8_t RS_PKT_TYPE_PEER_CONFIG = 0x01;
|
||||
const uint8_t RS_PKT_TYPE_CACHE_CONFIG = 0x02;
|
||||
const uint8_t RS_PKT_TYPE_FILE_CONFIG = 0x03;
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
|
|
@ -38,17 +43,19 @@ class RsPeerConfig: public RsItem
|
|||
public:
|
||||
RsPeerConfig()
|
||||
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
|
||||
RS_PKT_TYPE_PEER_CONFIG, 0)
|
||||
RS_PKT_TYPE_PEER_CONFIG,
|
||||
RS_PKT_SUBTYPE_DEFAULT)
|
||||
{ return; }
|
||||
virtual ~RsPeerConfig();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
RsTlvPeerId peerid; /* Mandatory */
|
||||
RsTlvPeerFingerprint fpr; /* Mandatory */
|
||||
//RsTlvPeerId peerid; /* Mandatory */
|
||||
//RsTlvPeerFingerprint fpr; /* Mandatory */
|
||||
|
||||
struct sockaddr_in lastaddr; /* Mandatory */
|
||||
struct sockaddr_in localaddr; /* Mandatory */
|
||||
struct sockaddr_in serveraddr; /* Mandatory */
|
||||
//struct sockaddr_in lastaddr; /* Mandatory */
|
||||
//struct sockaddr_in localaddr; /* Mandatory */
|
||||
//struct sockaddr_in serveraddr; /* Mandatory */
|
||||
|
||||
uint32_t status; /* Mandatory */
|
||||
|
||||
|
|
@ -82,12 +89,14 @@ class RsCacheConfig: public RsItem
|
|||
public:
|
||||
RsCacheConfig()
|
||||
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
|
||||
RS_PKT_TYPE_CACHE_CONFIG, 0)
|
||||
RS_PKT_TYPE_CACHE_CONFIG,
|
||||
RS_PKT_SUBTYPE_DEFAULT)
|
||||
{ return; }
|
||||
virtual ~RsCacheConfig();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
RsTlvPeerId peerid; /* Mandatory */
|
||||
//RsTlvPeerId peerid; /* Mandatory */
|
||||
uint32_t cacheid; /* Mandatory */
|
||||
|
||||
std::string path; /* Mandatory */
|
||||
|
|
@ -116,4 +125,65 @@ virtual RsItem * deserialise(void *data, uint32_t *size);
|
|||
|
||||
/**************************************************************************/
|
||||
|
||||
#define FT_STATE_FAILED 0
|
||||
#define FT_STATE_OKAY 1
|
||||
#define FT_STATE_WAITING 2
|
||||
#define FT_STATE_DOWNLOADING 3
|
||||
#define FT_STATE_COMPLETE 4
|
||||
|
||||
class RsFileTransfer: public RsItem
|
||||
{
|
||||
public:
|
||||
RsFileTransfer()
|
||||
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
|
||||
RS_PKT_TYPE_FILE_CONFIG,
|
||||
RS_PKT_SUBTYPE_DEFAULT)
|
||||
{ return; }
|
||||
virtual ~RsFileTransfer();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
RsTlvFileItem file;
|
||||
RsTlvPeerIdSet allPeerIds;
|
||||
|
||||
std::string cPeerId;
|
||||
|
||||
uint16_t state;
|
||||
uint16_t in;
|
||||
|
||||
uint64_t transferred;
|
||||
uint32_t crate;
|
||||
uint32_t trate;
|
||||
|
||||
|
||||
uint32_t lrate;
|
||||
uint32_t ltransfer;
|
||||
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
class RsFileTransferSerialiser: public RsSerialType
|
||||
{
|
||||
public:
|
||||
RsFileTransferSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
|
||||
RS_PKT_TYPE_FILE_CONFIG)
|
||||
{ return; }
|
||||
virtual ~RsFileTransferSerialiser() { return; }
|
||||
|
||||
virtual uint32_t size(RsItem *);
|
||||
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
virtual RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
private:
|
||||
|
||||
virtual uint32_t sizeTransfer(RsFileTransfer *);
|
||||
virtual bool serialiseTransfer(RsFileTransfer *item, void *data, uint32_t *size);
|
||||
virtual RsFileTransfer * deserialiseTransfer(void *data, uint32_t *size);
|
||||
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#endif /* RS_CONFIG_ITEMS_SERIALISER_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue