2011-11-21 02:49:38 -05:00
|
|
|
#ifndef RS_DSDV_ITEMS_H
|
|
|
|
#define RS_DSDV_ITEMS_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/serialiser: rsdsdvitems.h
|
|
|
|
*
|
|
|
|
* RetroShare Serialiser.
|
|
|
|
*
|
|
|
|
* Copyright 2011-2011 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".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "serialiser/rsserviceids.h"
|
|
|
|
#include "serialiser/rsserial.h"
|
2011-11-21 09:38:13 -05:00
|
|
|
#include "serialiser/rstlvbase.h"
|
|
|
|
#include "serialiser/rstlvtypes.h"
|
2011-11-21 02:49:38 -05:00
|
|
|
#include "serialiser/rstlvdsdv.h"
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
#define RS_PKT_SUBTYPE_DSDV_ROUTE 0x01
|
2011-11-21 09:38:13 -05:00
|
|
|
#define RS_PKT_SUBTYPE_DSDV_DATA 0x02
|
2011-11-21 02:49:38 -05:00
|
|
|
|
|
|
|
class RsDsdvRouteItem: public RsItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsDsdvRouteItem()
|
|
|
|
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DSDV,
|
|
|
|
RS_PKT_SUBTYPE_DSDV_ROUTE)
|
2011-11-29 12:14:51 -05:00
|
|
|
{
|
|
|
|
setPriorityLevel(QOS_PRIORITY_RS_DSDV_ROUTE);
|
|
|
|
return;
|
|
|
|
}
|
2011-11-21 02:49:38 -05:00
|
|
|
virtual ~RsDsdvRouteItem();
|
|
|
|
virtual void clear();
|
|
|
|
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
|
|
|
|
|
|
|
RsTlvDsdvEntrySet routes;
|
|
|
|
};
|
|
|
|
|
2011-11-21 09:38:13 -05:00
|
|
|
class RsDsdvDataItem: public RsItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsDsdvDataItem()
|
|
|
|
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DSDV,
|
|
|
|
RS_PKT_SUBTYPE_DSDV_DATA), data(TLV_TYPE_BIN_GENERIC)
|
2011-11-29 12:14:51 -05:00
|
|
|
{
|
|
|
|
setPriorityLevel(QOS_PRIORITY_RS_DSDV_DATA);
|
|
|
|
return;
|
|
|
|
}
|
2011-11-21 09:38:13 -05:00
|
|
|
virtual ~RsDsdvDataItem();
|
|
|
|
virtual void clear();
|
|
|
|
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
|
|
|
|
|
|
|
RsTlvDsdvEndPoint src;
|
|
|
|
RsTlvDsdvEndPoint dest;
|
|
|
|
uint32_t ttl;
|
|
|
|
RsTlvBinaryData data;
|
|
|
|
};
|
|
|
|
|
2011-11-21 02:49:38 -05:00
|
|
|
class RsDsdvSerialiser: public RsSerialType
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsDsdvSerialiser()
|
|
|
|
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DSDV)
|
|
|
|
{ return; }
|
|
|
|
virtual ~RsDsdvSerialiser()
|
|
|
|
{ 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:
|
|
|
|
|
2011-11-21 09:38:13 -05:00
|
|
|
virtual uint32_t sizeRoute(RsDsdvRouteItem *);
|
|
|
|
virtual bool serialiseRoute(RsDsdvRouteItem *item, void *data, uint32_t *size);
|
|
|
|
virtual RsDsdvRouteItem *deserialiseRoute(void *data, uint32_t *size);
|
|
|
|
|
|
|
|
virtual uint32_t sizeData(RsDsdvDataItem *);
|
|
|
|
virtual bool serialiseData(RsDsdvDataItem *item, void *data, uint32_t *size);
|
|
|
|
virtual RsDsdvDataItem *deserialiseData(void *data, uint32_t *size);
|
2011-11-21 02:49:38 -05:00
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
#endif /* RS_DSDV_ITEMS_H */
|
|
|
|
|
|
|
|
|