2007-12-11 19:54:42 -05:00
|
|
|
/*
|
|
|
|
* libretroshare/src/serialiser: rsdiscitems.h
|
|
|
|
*
|
|
|
|
* Serialiser for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2004-2008 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef RS_DISC_ITEMS_H
|
|
|
|
#define RS_DISC_ITEMS_H
|
|
|
|
|
|
|
|
#include "serialiser/rsserial.h"
|
|
|
|
#include "serialiser/rstlvbase.h"
|
|
|
|
#include "serialiser/rstlvtypes.h"
|
|
|
|
#include "serialiser/rsserviceids.h"
|
2009-11-11 11:43:51 -05:00
|
|
|
#include "serialiser/rsconfigitems.h"
|
2009-06-28 16:57:02 -04:00
|
|
|
|
2010-01-19 14:15:22 -05:00
|
|
|
//const uint8_t RS_PKT_SUBTYPE_DISC_OWN = 0x01;
|
2009-05-25 07:38:47 -04:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_DISC_REPLY = 0x02;
|
2010-01-19 14:15:22 -05:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_DISC_ASK_INFO = 0x03;
|
2009-12-18 12:52:11 -05:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_DISC_VERSION = 0x05;
|
2009-12-22 05:41:19 -05:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_DISC_HEARTBEAT = 0x06;
|
2007-12-11 19:54:42 -05:00
|
|
|
|
|
|
|
class RsDiscItem: public RsItem
|
|
|
|
{
|
|
|
|
protected:
|
2009-06-23 17:36:02 -04:00
|
|
|
RsDiscItem(uint8_t subtype) :RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DISC, subtype) {}
|
|
|
|
};
|
2007-12-11 19:54:42 -05:00
|
|
|
|
2009-06-28 16:57:02 -04:00
|
|
|
|
2010-01-19 14:15:22 -05:00
|
|
|
//class RsDiscOwnItem: public RsDiscItem
|
|
|
|
//{
|
|
|
|
// public:
|
|
|
|
//
|
|
|
|
// RsDiscOwnItem() :RsDiscItem(RS_PKT_SUBTYPE_DISC_OWN ) {}
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// virtual ~RsDiscOwnItem();
|
|
|
|
//
|
|
|
|
// virtual void clear();
|
|
|
|
// virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
|
|
|
//
|
|
|
|
// //use for transmitting ip address list
|
|
|
|
// std::list<IpAddressTimed> ipAddressList;
|
|
|
|
//
|
|
|
|
// //use for transmitting my own adress list
|
|
|
|
// struct sockaddr_in laddr;
|
|
|
|
// struct sockaddr_in saddr;
|
|
|
|
//
|
|
|
|
// // time frame of recent connections.
|
|
|
|
// uint16_t contact_tf;
|
|
|
|
// // flags...
|
|
|
|
// uint32_t discFlags;
|
|
|
|
//};
|
2007-12-11 19:54:42 -05:00
|
|
|
|
|
|
|
class RsDiscReply: public RsDiscItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsDiscReply()
|
2010-01-13 16:22:52 -05:00
|
|
|
:RsDiscItem(RS_PKT_SUBTYPE_DISC_REPLY)
|
2007-12-11 19:54:42 -05:00
|
|
|
{ return; }
|
|
|
|
|
|
|
|
virtual ~RsDiscReply();
|
|
|
|
|
2009-06-28 16:57:02 -04:00
|
|
|
virtual void clear();
|
2007-12-11 19:54:42 -05:00
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
|
|
|
|
2009-11-11 11:49:11 -05:00
|
|
|
//use for transmitting ip address list
|
2010-01-13 16:33:54 -05:00
|
|
|
std::list<RsPeerNetItem> rsPeerList;
|
2009-11-11 11:43:51 -05:00
|
|
|
|
|
|
|
//use for transmitting my own adress list
|
2010-01-13 16:33:54 -05:00
|
|
|
// struct sockaddr_in currentladdr;
|
|
|
|
// struct sockaddr_in currentsaddr;
|
2009-06-23 17:36:02 -04:00
|
|
|
|
|
|
|
// time frame of recent connections.
|
2010-01-13 16:33:54 -05:00
|
|
|
//uint16_t contact_tf;
|
2009-06-23 17:36:02 -04:00
|
|
|
// flags...
|
2010-01-13 16:33:54 -05:00
|
|
|
//uint32_t discFlags;
|
2009-06-23 17:36:02 -04:00
|
|
|
|
2010-01-13 16:33:54 -05:00
|
|
|
std::string aboutId;
|
2010-01-13 16:22:52 -05:00
|
|
|
std::string certGPG;
|
2007-12-11 19:54:42 -05:00
|
|
|
};
|
|
|
|
|
2010-01-19 14:15:22 -05:00
|
|
|
class RsDiscAskInfo: public RsDiscItem
|
2009-05-25 07:38:47 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2010-01-19 14:15:22 -05:00
|
|
|
RsDiscAskInfo()
|
|
|
|
:RsDiscItem(RS_PKT_SUBTYPE_DISC_ASK_INFO)
|
2009-05-25 07:38:47 -04:00
|
|
|
{ return; }
|
|
|
|
|
2010-01-19 14:15:22 -05:00
|
|
|
virtual ~RsDiscAskInfo();
|
2009-05-25 07:38:47 -04:00
|
|
|
|
2009-06-28 16:57:02 -04:00
|
|
|
virtual void clear();
|
2009-05-25 07:38:47 -04:00
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
|
|
|
|
2010-01-19 14:15:22 -05:00
|
|
|
std::string gpg_id;
|
2009-05-25 07:38:47 -04:00
|
|
|
};
|
|
|
|
|
2009-06-28 16:57:02 -04:00
|
|
|
class RsDiscVersion: public RsDiscItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsDiscVersion() :RsDiscItem(RS_PKT_SUBTYPE_DISC_VERSION)
|
|
|
|
{ return; }
|
|
|
|
|
|
|
|
virtual ~RsDiscVersion();
|
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
|
|
|
|
|
|
|
std::string version;
|
|
|
|
};
|
|
|
|
|
2009-12-22 05:41:19 -05:00
|
|
|
class RsDiscHeartbeat: public RsDiscItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsDiscHeartbeat() :RsDiscItem(RS_PKT_SUBTYPE_DISC_HEARTBEAT)
|
|
|
|
{ return; }
|
|
|
|
|
|
|
|
virtual ~RsDiscHeartbeat();
|
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
|
|
|
};
|
|
|
|
|
2007-12-11 19:54:42 -05:00
|
|
|
class RsDiscSerialiser: public RsSerialType
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsDiscSerialiser()
|
|
|
|
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DISC)
|
|
|
|
{ return; }
|
|
|
|
|
|
|
|
virtual ~RsDiscSerialiser() { 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:
|
|
|
|
|
2010-01-19 14:15:22 -05:00
|
|
|
virtual uint32_t sizeAskInfo(RsDiscAskInfo *);
|
|
|
|
virtual bool serialiseAskInfo(RsDiscAskInfo *item, void *data, uint32_t *size);
|
|
|
|
virtual RsDiscAskInfo *deserialiseAskInfo(void *data, uint32_t *size);
|
2007-12-11 19:54:42 -05:00
|
|
|
|
|
|
|
virtual uint32_t sizeReply(RsDiscReply *);
|
|
|
|
virtual bool serialiseReply (RsDiscReply *item, void *data, uint32_t *size);
|
|
|
|
virtual RsDiscReply *deserialiseReply(void *data, uint32_t *size);
|
|
|
|
|
2010-01-19 14:15:22 -05:00
|
|
|
//virtual uint32_t sizeIssuer(RsDiscIssuer *);
|
|
|
|
//virtual bool serialiseIssuer (RsDiscIssuer *item, void *data, uint32_t *size);
|
|
|
|
//virtual RsDiscIssuer *deserialiseIssuer(void *data, uint32_t *size);
|
2009-05-25 07:38:47 -04:00
|
|
|
|
2009-06-28 16:57:02 -04:00
|
|
|
virtual uint32_t sizeVersion(RsDiscVersion *);
|
|
|
|
virtual bool serialiseVersion(RsDiscVersion *item, void *data, uint32_t *size);
|
|
|
|
virtual RsDiscVersion *deserialiseVersion(void *data, uint32_t *size);
|
|
|
|
|
2009-12-22 05:41:19 -05:00
|
|
|
virtual uint32_t sizeHeartbeat(RsDiscHeartbeat *);
|
|
|
|
virtual bool serialiseHeartbeat(RsDiscHeartbeat *item, void *data, uint32_t *size);
|
|
|
|
virtual RsDiscHeartbeat *deserialiseHeartbeat(void *data, uint32_t *size);
|
|
|
|
|
2007-12-11 19:54:42 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // RS_DISC_ITEMS_H
|
|
|
|
|