2012-05-01 16:52:07 -04:00
|
|
|
#ifndef RSNXSITEMS_H
|
|
|
|
#define RSNXSITEMS_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/serialiser: rsnxssitems.h
|
|
|
|
*
|
|
|
|
* RetroShare Serialiser.
|
|
|
|
*
|
|
|
|
* Copyright 2012 Christopher Evi-Parker, 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"
|
|
|
|
#include "serialiser/rstlvbase.h"
|
|
|
|
#include "serialiser/rstlvtypes.h"
|
|
|
|
#include "serialiser/rstlvkeys.h"
|
|
|
|
|
2012-07-24 14:55:32 -04:00
|
|
|
#include "gxs/rsgxsdata.h"
|
|
|
|
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP = 0x0001;
|
|
|
|
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP_ITEM = 0x0002;
|
2012-05-21 18:07:43 -04:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_NXS_GRP = 0x0004;
|
2012-06-07 16:43:12 -04:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_MSG_ITEM = 0x0008;
|
|
|
|
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_MSG = 0x0010;
|
2012-05-21 18:07:43 -04:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_NXS_MSG = 0x0020;
|
2012-06-05 10:46:18 -04:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_NXS_TRANS = 0x0040;
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
|
|
|
|
// possibility create second service to deal with this functionality
|
|
|
|
|
|
|
|
const uint8_t RS_PKT_SUBTYPE_NXS_EXTENDED = 0x0080; // in order to extend supported pkt subtypes
|
|
|
|
const uint8_t RS_PKT_SUBTYPE_EXT_SEARCH_GRP = 0x0001;
|
|
|
|
const uint8_t RS_PKT_SUBTYPE_EXT_SEARCH_MSG = 0x0002;
|
|
|
|
const uint8_t RS_PKT_SUBTYPE_EXT_DELETE_GRP = 0x0004;
|
|
|
|
const uint8_t RS_PKT_SUBTYPE_EXT_DELETE_MSG = 0x0008;
|
2012-06-05 10:46:18 -04:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_EXT_SEARCH_REQ = 0x0010;
|
2012-05-01 16:52:07 -04:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Base class for Network exchange service
|
2012-05-05 15:55:24 -04:00
|
|
|
* Main purpose is for rtti based routing used in the
|
|
|
|
* serialisation and deserialisation of NXS packets
|
2012-05-01 16:52:07 -04:00
|
|
|
*
|
|
|
|
* Service type is set by plugin service
|
|
|
|
*/
|
2012-05-06 10:29:50 -04:00
|
|
|
class RsNxsItem : public RsItem
|
2012-05-01 16:52:07 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2012-05-06 10:29:50 -04:00
|
|
|
RsNxsItem(uint16_t servtype, uint8_t subtype)
|
2012-06-07 16:43:12 -04:00
|
|
|
: RsItem(RS_PKT_VERSION_SERVICE, servtype, subtype), transactionNumber(0) { return; }
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-05-06 10:29:50 -04:00
|
|
|
virtual void clear() = 0;
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0) = 0;
|
2012-06-07 16:43:12 -04:00
|
|
|
|
|
|
|
uint32_t transactionNumber; // set to zero if this is not a transaction item
|
2012-05-01 16:52:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Use to request grp list from peer
|
|
|
|
* Server may advise client peer to use sync file
|
|
|
|
* while serving his request. This results
|
|
|
|
*/
|
2012-06-07 16:43:12 -04:00
|
|
|
class RsNxsSyncGrp : public RsNxsItem {
|
2012-05-01 16:52:07 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static const uint8_t FLAG_USE_SYNC_HASH;
|
2012-06-03 14:09:38 -04:00
|
|
|
static const uint8_t FLAG_ONLY_CURRENT; // only send most current version of grps / ignores sync hash
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncGrp(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_SYNC_GRP) { clear(); return;}
|
2012-05-06 10:29:50 -04:00
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
|
|
|
uint8_t flag; // advises whether to use sync hash
|
|
|
|
uint32_t syncAge; // how far back to sync data
|
|
|
|
std::string syncHash; // use to determine if changes that have occured since last hash
|
|
|
|
|
|
|
|
|
2012-06-03 14:09:38 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* This RsNxsItem is for use in enabling transactions
|
|
|
|
* in order to guaranttee a collection of item have been
|
|
|
|
* received
|
|
|
|
*/
|
|
|
|
class RsNxsTransac : public RsNxsItem {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-07-14 13:59:54 -04:00
|
|
|
static const uint16_t FLAG_STATE_MASK = 0xff;
|
|
|
|
static const uint16_t FLAG_TYPE_MASK = 0xff00;
|
2012-06-11 17:56:23 -04:00
|
|
|
|
2012-07-12 16:18:58 -04:00
|
|
|
/** transaction state **/
|
2012-06-03 14:09:38 -04:00
|
|
|
static const uint16_t FLAG_BEGIN_P1;
|
|
|
|
static const uint16_t FLAG_BEGIN_P2;
|
2012-06-07 16:43:12 -04:00
|
|
|
static const uint16_t FLAG_END_SUCCESS;
|
2012-06-03 14:09:38 -04:00
|
|
|
static const uint16_t FLAG_CANCEL;
|
2012-06-07 16:43:12 -04:00
|
|
|
static const uint16_t FLAG_END_FAIL_NUM;
|
|
|
|
static const uint16_t FLAG_END_FAIL_TIMEOUT;
|
|
|
|
static const uint16_t FLAG_END_FAIL_FULL;
|
2012-06-05 10:46:18 -04:00
|
|
|
|
2012-06-03 14:09:38 -04:00
|
|
|
|
|
|
|
/** transaction type **/
|
|
|
|
static const uint16_t FLAG_TYPE_GRP_LIST_RESP;
|
|
|
|
static const uint16_t FLAG_TYPE_MSG_LIST_RESP;
|
|
|
|
static const uint16_t FLAG_TYPE_GRP_LIST_REQ;
|
2012-06-05 10:46:18 -04:00
|
|
|
static const uint16_t FLAG_TYPE_MSG_LIST_REQ;
|
|
|
|
static const uint16_t FLAG_TYPE_GRPS;
|
|
|
|
static const uint16_t FLAG_TYPE_MSGS;
|
2012-06-03 14:09:38 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsTransac(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_TRANS) { clear(); return; }
|
2012-06-05 10:46:18 -04:00
|
|
|
virtual ~RsNxsTransac() { return ; }
|
2012-06-03 14:09:38 -04:00
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
2012-06-03 14:09:38 -04:00
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
uint16_t transactFlag;
|
|
|
|
uint32_t nItems;
|
2012-07-14 13:59:54 -04:00
|
|
|
uint32_t timestamp;
|
2012-05-01 16:52:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Use to send to peer list of grps
|
|
|
|
* held by server peer
|
|
|
|
*/
|
2012-06-07 16:43:12 -04:00
|
|
|
class RsNxsSyncGrpItem : public RsNxsItem
|
2012-05-01 16:52:07 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-05-03 17:49:55 -04:00
|
|
|
static const uint8_t FLAG_REQUEST;
|
|
|
|
static const uint8_t FLAG_RESPONSE;
|
2012-05-21 18:07:43 -04:00
|
|
|
static const uint8_t FLAG_USE_SYNC_HASH;
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncGrpItem(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_SYNC_GRP_ITEM) { clear(); return ; }
|
|
|
|
virtual ~RsNxsSyncGrpItem() { return; }
|
2012-05-06 10:29:50 -04:00
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
|
|
|
|
|
|
|
|
2012-05-03 17:49:55 -04:00
|
|
|
uint8_t flag; // request or response
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-06-26 15:52:01 -04:00
|
|
|
uint32_t publishTs; // to compare to Ts of receiving peer's grp of same id
|
|
|
|
|
|
|
|
/// grpId of grp held by sending peer
|
2012-05-24 18:38:59 -04:00
|
|
|
std::string grpId;
|
2012-05-01 16:52:07 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Contains serialised group items
|
|
|
|
* Each item corresponds to a group which needs to be
|
|
|
|
* deserialised
|
|
|
|
*/
|
2012-05-21 18:07:43 -04:00
|
|
|
class RsNxsGrp : public RsNxsItem
|
2012-05-01 16:52:07 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2012-05-21 18:07:43 -04:00
|
|
|
|
2012-07-26 17:48:54 -04:00
|
|
|
RsNxsGrp(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_GRP), grp(servtype), meta(servtype),
|
|
|
|
metaData(NULL) { clear(); return; }
|
|
|
|
virtual ~RsNxsGrp() { if(metaData) delete metaData; }
|
2012-05-06 10:29:50 -04:00
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
std::string grpId; /// group Id, needed to complete version Id (ncvi)
|
2012-06-26 15:52:01 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
RsTlvBinaryData grp; /// actual group data
|
2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
/*!
|
2012-08-12 16:46:21 -04:00
|
|
|
* This should contains all data
|
2012-06-26 15:52:01 -04:00
|
|
|
* which is not specific to the Gxs service data
|
|
|
|
*/
|
|
|
|
RsTlvBinaryData meta;
|
|
|
|
|
2012-07-22 17:38:15 -04:00
|
|
|
// deserialised metaData, this is not serialised
|
2012-07-24 14:55:32 -04:00
|
|
|
RsGxsGrpMetaData* metaData;
|
2012-05-01 16:52:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Use to request list of msg held by peer
|
|
|
|
* for a given group
|
|
|
|
*/
|
2012-06-07 16:43:12 -04:00
|
|
|
class RsNxsSyncMsg : public RsNxsItem
|
2012-05-01 16:52:07 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-05-05 15:55:24 -04:00
|
|
|
static const uint8_t FLAG_USE_SYNC_HASH;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncMsg(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_SYNC_MSG) { clear(); return; }
|
2012-05-06 10:29:50 -04:00
|
|
|
|
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
|
|
|
std::string grpId;
|
2012-05-05 15:55:24 -04:00
|
|
|
uint8_t flag;
|
2012-05-03 17:49:55 -04:00
|
|
|
uint32_t syncAge;
|
2012-05-05 15:55:24 -04:00
|
|
|
std::string syncHash;
|
2012-05-01 16:52:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Use to send list msgs for a group held by
|
|
|
|
* a peer
|
|
|
|
*/
|
2012-06-07 16:43:12 -04:00
|
|
|
class RsNxsSyncMsgItem : public RsNxsItem
|
2012-05-01 16:52:07 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-05-03 17:49:55 -04:00
|
|
|
static const uint8_t FLAG_REQUEST;
|
2012-05-21 18:07:43 -04:00
|
|
|
static const uint8_t FLAG_RESPONSE;
|
|
|
|
static const uint8_t FLAG_USE_SYNC_HASH;
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncMsgItem(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_SYNC_MSG_ITEM) { clear(); return; }
|
2012-05-06 10:29:50 -04:00
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-05-05 15:55:24 -04:00
|
|
|
uint8_t flag; // response/req
|
2012-05-01 16:52:07 -04:00
|
|
|
std::string grpId;
|
2012-05-24 18:38:59 -04:00
|
|
|
std::string msgId;
|
2012-05-01 16:52:07 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Used to respond to a RsGrpMsgsReq
|
|
|
|
* with message items satisfying request
|
|
|
|
*/
|
2012-05-21 18:07:43 -04:00
|
|
|
class RsNxsMsg : public RsNxsItem
|
2012-05-01 16:52:07 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-08-06 17:00:38 -04:00
|
|
|
RsNxsMsg(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_MSG), msg(servtype), meta(servtype),
|
|
|
|
metaData(NULL) { clear(); return; }
|
|
|
|
~RsNxsMsg() { if(metaData) delete metaData; }
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-05-06 10:29:50 -04:00
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
std::string grpId; /// group id, forms part of version id
|
|
|
|
std::string msgId; /// msg id
|
2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* This should contains all the data
|
|
|
|
* which is not specific to the Gxs service data
|
|
|
|
*/
|
|
|
|
RsTlvBinaryData meta;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* This contains Gxs specific data
|
|
|
|
* only client of API knows who to decode this
|
|
|
|
*/
|
2012-05-21 18:07:43 -04:00
|
|
|
RsTlvBinaryData msg;
|
|
|
|
|
2012-07-26 17:48:54 -04:00
|
|
|
RsGxsMsgMetaData* metaData;
|
|
|
|
|
2012-05-01 16:52:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Used to request a search of user data
|
|
|
|
*/
|
2012-05-06 10:29:50 -04:00
|
|
|
class RsNxsSearchReq : public RsNxsItem
|
2012-05-01 16:52:07 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
RsNxsSearchReq(uint16_t servtype): RsNxsItem(servtype, RS_PKT_SUBTYPE_EXT_SEARCH_REQ), serviceSearchItem(servtype) { return; }
|
2012-05-21 18:07:43 -04:00
|
|
|
virtual ~RsNxsSearchReq() { return;}
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
virtual void clear() { return;}
|
2012-05-06 10:29:50 -04:00
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent) { return out; }
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
uint8_t nHops; /// how many peers to jump to
|
|
|
|
uint32_t token; // search token
|
|
|
|
RsTlvBinaryData serviceSearchItem; // service aware of item class
|
|
|
|
uint32_t expiration; // expiration date
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* used to extend data types processed
|
|
|
|
*/
|
|
|
|
class RsNxsExtended : public RsNxsItem
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsNxsExtended(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_EXTENDED), extData(servtype) { return; }
|
|
|
|
virtual ~RsNxsExtended() { return; }
|
|
|
|
|
|
|
|
virtual void clear() {}
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
|
|
|
|
|
|
|
RsTlvBinaryData extData;
|
|
|
|
uint32_t type;
|
2012-05-01 16:52:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Used to respond to a RsGrpSearchReq
|
|
|
|
* with grpId/MsgIds that satisfy search request
|
|
|
|
*/
|
2012-05-21 18:07:43 -04:00
|
|
|
class RsNxsSearchResultMsg
|
2012-05-01 16:52:07 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
RsNxsSearchResultMsg() : context(0) { return;}
|
|
|
|
void clear() {}
|
|
|
|
std::ostream &print(std::ostream &out, uint16_t indent) { return out; }
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
uint32_t token; // search token to be redeemed
|
|
|
|
RsTlvBinaryData context; // used by client service
|
|
|
|
std::string msgId;
|
|
|
|
std::string grpId;
|
|
|
|
RsTlvKeySignature idSign;
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
uint32_t expiration; // expiration date
|
|
|
|
};
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
/*!
|
|
|
|
* Used to respond to a RsGrpSearchReq
|
|
|
|
* with grpId/MsgIds that satisfy search request
|
|
|
|
*/
|
|
|
|
class RsNxsSearchResultGrp
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsNxsSearchResultGrp();
|
|
|
|
void clear() {}
|
|
|
|
std::ostream &print(std::ostream &out, uint16_t indent) { return out; }
|
|
|
|
|
|
|
|
uint32_t token; // search token to be redeemed
|
|
|
|
|
|
|
|
RsTlvBinaryData context; // used by client service
|
|
|
|
|
|
|
|
std::string grpId;
|
|
|
|
RsTlvKeySignature adminSign;
|
|
|
|
|
|
|
|
uint32_t expiration; // expiration date
|
2012-05-01 16:52:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
class RsNxsDeleteMsg
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsNxsDeleteMsg() { return; }
|
|
|
|
|
|
|
|
std::string msgId;
|
|
|
|
std::string grpId;
|
|
|
|
RsTlvKeySignature deleteSign; // ( msgId + grpId + msg data ) sign //TODO: add warning not to place msgId+grpId in msg!
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class RsNxsDeleteGrp
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsNxsDeleteGrp() { return;}
|
|
|
|
|
|
|
|
std::string grpId;
|
|
|
|
RsTlvKeySignature idSign;
|
|
|
|
RsTlvKeySignature deleteSign; // (grpId + grp data) sign // TODO: add warning not to place grpId in msg
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-01 16:52:07 -04:00
|
|
|
class RsNxsSerialiser : public RsSerialType
|
|
|
|
{
|
2012-05-06 10:29:50 -04:00
|
|
|
public:
|
2012-05-01 16:52:07 -04:00
|
|
|
|
|
|
|
RsNxsSerialiser(uint16_t servtype) :
|
2012-05-05 15:55:24 -04:00
|
|
|
RsSerialType(RS_PKT_VERSION_SERVICE, servtype), SERVICE_TYPE(servtype) { return; }
|
2012-05-01 16:52:07 -04:00
|
|
|
|
|
|
|
virtual ~RsNxsSerialiser() { return; }
|
|
|
|
|
2012-05-03 17:49:55 -04:00
|
|
|
virtual uint32_t size(RsItem *item);
|
2012-05-01 16:52:07 -04:00
|
|
|
virtual bool serialise(RsItem *item, void *data, uint32_t *size);
|
|
|
|
virtual RsItem* deserialise(void *data, uint32_t *size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
/* for RS_PKT_SUBTYPE_SYNC_GRP */
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
virtual uint32_t sizeNxsSyncGrp(RsNxsSyncGrp* item);
|
|
|
|
virtual bool serialiseNxsSyncGrp(RsNxsSyncGrp *item, void *data, uint32_t *size);
|
|
|
|
virtual RsNxsSyncGrp* deserialNxsSyncGrp(void *data, uint32_t *size);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
/* for RS_PKT_SUBTYPE_SYNC_GRP_ITEM */
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
virtual uint32_t sizeNxsSyncGrpItem(RsNxsSyncGrpItem* item);
|
|
|
|
virtual bool serialiseNxsSyncGrpItem(RsNxsSyncGrpItem *item, void *data, uint32_t *size);
|
|
|
|
virtual RsNxsSyncGrpItem* deserialNxsSyncGrpItem(void *data, uint32_t *size);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
/* for RS_PKT_SUBTYPE_NXS_GRP */
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
virtual uint32_t sizeNxsGrp(RsNxsGrp* item);
|
|
|
|
virtual bool serialiseNxsGrp(RsNxsGrp *item, void *data, uint32_t *size);
|
|
|
|
virtual RsNxsGrp* deserialNxsGrp(void *data, uint32_t *size);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
|
|
|
/* for RS_PKT_SUBTYPE_SYNC_MSG */
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
virtual uint32_t sizeNxsSyncMsg(RsNxsSyncMsg* item);
|
|
|
|
virtual bool serialiseNxsSyncMsg(RsNxsSyncMsg *item, void *data, uint32_t *size);
|
|
|
|
virtual RsNxsSyncMsg* deserialNxsSyncMsg(void *data, uint32_t *size);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
/* RS_PKT_SUBTYPE_SYNC_MSG_ITEM */
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
virtual uint32_t sizeNxsSyncMsgItem(RsNxsSyncMsgItem* item);
|
|
|
|
virtual bool serialiseNxsSynMsgItem(RsNxsSyncMsgItem* item, void *data, uint32_t* size);
|
|
|
|
virtual RsNxsSyncMsgItem* deserialNxsSyncMsgItem(void *data, uint32_t *size);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
/* RS_PKT_SUBTYPE_NXS_MSG */
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
virtual uint32_t sizeNxsMsg(RsNxsMsg* item);
|
|
|
|
virtual bool serialiseNxsMsg(RsNxsMsg* item, void* data, uint32_t* size);
|
|
|
|
virtual RsNxsMsg* deserialNxsMsg(void *data, uint32_t *size);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
/* RS_PKT_SUBTYPE_NXS_TRANS */
|
|
|
|
virtual uint32_t sizeNxsTrans(RsNxsTransac* item);
|
|
|
|
virtual bool serialiseNxsTrans(RsNxsTransac* item, void* data, uint32_t* size);
|
|
|
|
virtual RsNxsTransac* deserialNxsTrans(void* data, uint32_t *size);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
/* RS_PKT_SUBTYPE_EXTENDED */
|
|
|
|
virtual RsNxsExtended* deserialNxsExtended(void* data, uint32_t *size);
|
|
|
|
virtual uint32_t sizeNxsExtended(RsNxsExtended* item);
|
|
|
|
virtual bool serialiseNxsExtended(RsNxsExtended* item, void* data, uint32_t* size);
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2012-05-05 15:55:24 -04:00
|
|
|
private:
|
|
|
|
|
|
|
|
const uint16_t SERVICE_TYPE;
|
2012-05-01 16:52:07 -04:00
|
|
|
};
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
|
2012-05-01 16:52:07 -04:00
|
|
|
#endif // RSNXSITEMS_H
|