2012-05-01 16:52:07 -04:00
|
|
|
#include "rsnxsitems.h"
|
2012-05-05 15:55:24 -04:00
|
|
|
#include "rsbaseserial.h"
|
2012-05-01 16:52:07 -04:00
|
|
|
|
2013-02-27 16:16:03 -05:00
|
|
|
/***
|
|
|
|
* #define RSSERIAL_DEBUG 1
|
|
|
|
***/
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
const uint8_t RsNxsSyncGrpItem::FLAG_REQUEST = 0x001;
|
|
|
|
const uint8_t RsNxsSyncGrpItem::FLAG_RESPONSE = 0x002;
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
const uint8_t RsNxsSyncMsgItem::FLAG_REQUEST = 0x001;
|
|
|
|
const uint8_t RsNxsSyncMsgItem::FLAG_RESPONSE = 0x002;
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
const uint8_t RsNxsSyncGrp::FLAG_USE_SYNC_HASH = 0x001;
|
|
|
|
const uint8_t RsNxsSyncMsg::FLAG_USE_SYNC_HASH = 0x001;
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-07-12 16:18:58 -04:00
|
|
|
/** transaction state **/
|
|
|
|
const uint16_t RsNxsTransac::FLAG_BEGIN_P1 = 0x0001;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_BEGIN_P2 = 0x0002;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_END_SUCCESS = 0x0004;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_CANCEL = 0x0008;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_END_FAIL_NUM = 0x0010;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_END_FAIL_TIMEOUT = 0x0020;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_END_FAIL_FULL = 0x0040;
|
|
|
|
|
|
|
|
|
|
|
|
/** transaction type **/
|
|
|
|
const uint16_t RsNxsTransac::FLAG_TYPE_GRP_LIST_RESP = 0x0100;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_TYPE_MSG_LIST_RESP = 0x0200;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_TYPE_GRP_LIST_REQ = 0x0400;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_TYPE_MSG_LIST_REQ = 0x0800;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_TYPE_GRPS = 0x1000;
|
|
|
|
const uint16_t RsNxsTransac::FLAG_TYPE_MSGS = 0x2000;
|
|
|
|
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
uint32_t RsNxsSerialiser::size(RsItem *item) {
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
RsNxsGrp* ngp;
|
|
|
|
RsNxsMsg* nmg;
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncGrp* sg;
|
|
|
|
RsNxsSyncGrpItem* sgl;
|
|
|
|
RsNxsSyncMsg* sgm;
|
|
|
|
RsNxsSyncMsgItem* sgml;
|
2012-06-05 10:46:18 -04:00
|
|
|
RsNxsTransac* ntx;
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
if((sg = dynamic_cast<RsNxsSyncGrp*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
return sizeNxsSyncGrp(sg);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
}else if(( ntx = dynamic_cast<RsNxsTransac*>(item)) != NULL){
|
|
|
|
return sizeNxsTrans(ntx);
|
|
|
|
}
|
2012-06-11 17:56:23 -04:00
|
|
|
else if ((sgl = dynamic_cast<RsNxsSyncGrpItem*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
return sizeNxsSyncGrpItem(sgl);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
}else if ((sgm = dynamic_cast<RsNxsSyncMsg*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
return sizeNxsSyncMsg(sgm);
|
|
|
|
}else if ((sgml = dynamic_cast<RsNxsSyncMsgItem*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
return sizeNxsSyncMsgItem(sgml);
|
2012-05-21 18:07:43 -04:00
|
|
|
}else if((ngp = dynamic_cast<RsNxsGrp*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-06-05 10:46:18 -04:00
|
|
|
return sizeNxsGrp(ngp);
|
2012-05-21 18:07:43 -04:00
|
|
|
}else if((nmg = dynamic_cast<RsNxsMsg*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-06-05 10:46:18 -04:00
|
|
|
return sizeNxsMsg(nmg);
|
2012-06-11 17:56:23 -04:00
|
|
|
}else{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
std::cerr << "RsNxsSerialiser::size(): Could not find appropriate size function"
|
|
|
|
<< std::endl;
|
|
|
|
#endif
|
|
|
|
return 0;
|
2012-05-03 17:49:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RsItem* RsNxsSerialiser::deserialise(void *data, uint32_t *size) {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-06 10:29:50 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialise()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
|
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(SERVICE_TYPE != getRsItemService(rstype)))
|
|
|
|
{
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
2012-05-06 10:29:50 -04:00
|
|
|
switch(getRsItemSubType(rstype))
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
case RS_PKT_SUBTYPE_NXS_SYNC_GRP:
|
2012-06-11 17:56:23 -04:00
|
|
|
return deserialNxsSyncGrp(data, size);
|
2012-06-07 16:43:12 -04:00
|
|
|
case RS_PKT_SUBTYPE_NXS_SYNC_GRP_ITEM:
|
2012-06-11 17:56:23 -04:00
|
|
|
return deserialNxsSyncGrpItem(data, size);
|
2012-06-07 16:43:12 -04:00
|
|
|
case RS_PKT_SUBTYPE_NXS_SYNC_MSG:
|
2012-06-11 17:56:23 -04:00
|
|
|
return deserialNxsSyncMsg(data, size);
|
2012-06-07 16:43:12 -04:00
|
|
|
case RS_PKT_SUBTYPE_NXS_SYNC_MSG_ITEM:
|
2012-06-11 17:56:23 -04:00
|
|
|
return deserialNxsSyncMsgItem(data, size);
|
2012-05-21 18:07:43 -04:00
|
|
|
case RS_PKT_SUBTYPE_NXS_GRP:
|
|
|
|
return deserialNxsGrp(data, size);
|
|
|
|
case RS_PKT_SUBTYPE_NXS_MSG:
|
|
|
|
return deserialNxsMsg(data, size);
|
2012-06-05 10:46:18 -04:00
|
|
|
case RS_PKT_SUBTYPE_NXS_TRANS:
|
|
|
|
return deserialNxsTrans(data, size);
|
2012-05-21 18:07:43 -04:00
|
|
|
case RS_PKT_SUBTYPE_NXS_EXTENDED:
|
|
|
|
return deserialNxsExtended(data, size);
|
2012-05-03 17:49:55 -04:00
|
|
|
default:
|
|
|
|
{
|
2013-02-27 16:16:03 -05:00
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialise() : data has no type"
|
2012-05-03 17:49:55 -04:00
|
|
|
<< std::endl;
|
|
|
|
#endif
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool RsNxsSerialiser::serialise(RsItem *item, void *data, uint32_t *size){
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
RsNxsGrp* ngp;
|
|
|
|
RsNxsMsg* nmg;
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncGrp* sg;
|
|
|
|
RsNxsSyncGrpItem* sgl;
|
|
|
|
RsNxsSyncMsg* sgm;
|
|
|
|
RsNxsSyncMsgItem* sgml;
|
2012-05-21 18:07:43 -04:00
|
|
|
RsNxsExtended* nxt;
|
2012-06-05 10:46:18 -04:00
|
|
|
RsNxsTransac* ntx;
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
if((sg = dynamic_cast<RsNxsSyncGrp*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
return serialiseNxsSyncGrp(sg, data, size);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
}else if ((ntx = dynamic_cast<RsNxsTransac*>(item)) != NULL)
|
|
|
|
{
|
|
|
|
return serialiseNxsTrans(ntx, data, size);
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
}else if ((sgl = dynamic_cast<RsNxsSyncGrpItem*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
return serialiseNxsSyncGrpItem(sgl, data, size);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
}else if ((sgm = dynamic_cast<RsNxsSyncMsg*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
return serialiseNxsSyncMsg(sgm, data, size);
|
|
|
|
}else if ((sgml = dynamic_cast<RsNxsSyncMsgItem*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
return serialiseNxsSynMsgItem(sgml, data, size);
|
2012-05-21 18:07:43 -04:00
|
|
|
}else if((ngp = dynamic_cast<RsNxsGrp*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-05-21 18:07:43 -04:00
|
|
|
return serialiseNxsGrp(ngp, data, size);
|
|
|
|
}else if((nmg = dynamic_cast<RsNxsMsg*>(item)) != NULL)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
2012-05-21 18:07:43 -04:00
|
|
|
return serialiseNxsMsg(nmg, data, size);
|
|
|
|
}else if((nxt = dynamic_cast<RsNxsExtended*>(item)) != NULL){
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
return serialiseNxsExtended(nxt, data, size);
|
|
|
|
}
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
#ifdef NXS_DEBUG
|
|
|
|
std::cerr << "RsNxsSerialiser::serialise() item does not caste to know type"
|
|
|
|
<< std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
bool RsNxsSerialiser::serialiseNxsSynMsgItem(RsNxsSyncMsgItem *item, void *data, uint32_t *size){
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSynMsgItem()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
uint32_t tlvsize = sizeNxsSyncMsgItem(item);
|
2012-05-03 17:49:55 -04:00
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if(*size < tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSynMsgItem()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*size = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
/* RsNxsSyncMsgItem */
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->transactionNumber);
|
2012-05-05 15:55:24 -04:00
|
|
|
ok &= setRawUInt8(data, *size, &offset, item->flag);
|
|
|
|
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
2012-05-24 18:38:59 -04:00
|
|
|
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_MSGID, item->msgId);
|
2013-06-04 17:00:43 -04:00
|
|
|
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_NAME, item->authorId);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
if(offset != tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSynMsgItem() FAIL Size Error! " << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
if (!ok)
|
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSynMsgItem() NOK" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
bool RsNxsSerialiser::serialiseNxsMsg(RsNxsMsg *item, void *data, uint32_t *size)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsMsg()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
uint32_t tlvsize = sizeNxsMsg(item);
|
2012-05-03 17:49:55 -04:00
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if(*size < tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsMsg()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*size = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->transactionNumber);
|
2013-02-07 18:04:16 -05:00
|
|
|
ok &= setRawUInt8(data, *size, &offset, item->pos);
|
2012-05-21 18:07:43 -04:00
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSGID, item->msgId);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
|
|
|
ok &= item->msg.SetTlv(data, tlvsize, &offset);
|
2012-06-26 15:52:01 -04:00
|
|
|
ok &= item->meta.SetTlv(data, *size, &offset);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
if(offset != tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsMsg() FAIL Size Error! " << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
if (!ok)
|
|
|
|
{
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsMsg() NOK" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
bool RsNxsSerialiser::serialiseNxsGrp(RsNxsGrp *item, void *data, uint32_t *size){
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsGrp()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
uint32_t tlvsize = sizeNxsGrp(item);
|
2012-05-03 17:49:55 -04:00
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if(*size < tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsGrp()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*size = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
// grp id
|
2012-06-11 17:56:23 -04:00
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->transactionNumber);
|
2013-02-07 18:04:16 -05:00
|
|
|
ok &= setRawUInt8(data, *size, &offset, item->pos);
|
2012-05-21 18:07:43 -04:00
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
2012-05-24 18:38:59 -04:00
|
|
|
ok &= item->grp.SetTlv(data, tlvsize, &offset);
|
2012-06-26 15:52:01 -04:00
|
|
|
ok &= item->meta.SetTlv(data, *size, &offset);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
if(offset != tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsGrp() FAIL Size Error! " << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
if (!ok)
|
|
|
|
{
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsGrp() NOK" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
bool RsNxsSerialiser::serialiseNxsSyncGrp(RsNxsSyncGrp *item, void *data, uint32_t *size)
|
2012-05-01 16:52:07 -04:00
|
|
|
{
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSyncGrp()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
uint32_t tlvsize = sizeNxsSyncGrp(item);
|
2012-05-03 17:49:55 -04:00
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if(*size < tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSyncGrp()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*size = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->transactionNumber);
|
2012-05-05 15:55:24 -04:00
|
|
|
ok &= setRawUInt8(data, *size, &offset, item->flag);
|
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->syncAge);
|
|
|
|
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_HASH_SHA1, item->syncHash);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
if(offset != tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
std::cerr << "RsNxsSerialiser::serialiseSyncGrp() FAIL Size Error! " << std::endl;
|
|
|
|
#endif
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
std::cerr << "RsNxsSerialiser::serialiseSyncGrp() NOK" << std::endl;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
bool RsNxsSerialiser::serialiseNxsTrans(RsNxsTransac *item, void *data, uint32_t *size){
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsTrans()" << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
uint32_t tlvsize = sizeNxsTrans(item);
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if(*size < tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsTrans() size do not match" << std::endl;
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*size = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->transactionNumber);
|
2012-06-05 10:46:18 -04:00
|
|
|
ok &= setRawUInt16(data, *size, &offset, item->transactFlag);
|
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->nItems);
|
2012-07-14 13:59:54 -04:00
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->timestamp);
|
2012-06-05 10:46:18 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(offset != tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsTrans() FAIL Size Error! " << std::endl;
|
|
|
|
#endif
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsTrans() NOK" << std::endl;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
bool RsNxsSerialiser::serialiseNxsSyncGrpItem(RsNxsSyncGrpItem *item, void *data, uint32_t *size)
|
2012-05-03 17:49:55 -04:00
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSyncGrpItem()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
uint32_t tlvsize = sizeNxsSyncGrpItem(item);
|
2012-05-03 17:49:55 -04:00
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if(*size < tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-26 15:52:01 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSyncm() size do not match" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*size = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
2012-06-26 15:52:01 -04:00
|
|
|
/* RsNxsSyncm */
|
2012-05-03 17:49:55 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->transactionNumber);
|
2012-05-05 15:55:24 -04:00
|
|
|
ok &= setRawUInt8(data, *size, &offset, item->flag);
|
2012-05-24 18:38:59 -04:00
|
|
|
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
2012-06-26 15:52:01 -04:00
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->publishTs);
|
2013-06-04 17:00:43 -04:00
|
|
|
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_NAME, item->authorId);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
if(offset != tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-26 15:52:01 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSyncm( FAIL Size Error! " << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
if (!ok)
|
|
|
|
{
|
2012-06-26 15:52:01 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSyncm() NOK" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
bool RsNxsSerialiser::serialiseNxsSyncMsg(RsNxsSyncMsg *item, void *data, uint32_t *size){
|
2012-05-03 17:49:55 -04:00
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSyncMsg()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
uint32_t tlvsize = sizeNxsSyncMsg(item);
|
2012-05-03 17:49:55 -04:00
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if(*size < tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSyncMsg()" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*size = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->transactionNumber);
|
2012-05-05 15:55:24 -04:00
|
|
|
ok &= setRawUInt8(data, *size, &offset, item->flag);
|
|
|
|
ok &= setRawUInt32(data, *size, &offset, item->syncAge);
|
|
|
|
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_HASH_SHA1, item->syncHash);
|
|
|
|
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
2012-05-03 17:49:55 -04:00
|
|
|
|
|
|
|
if(offset != tlvsize){
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSyncMsg() FAIL Size Error! " << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
#endif
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
if (!ok)
|
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::serialiseNxsSyncMsg( NOK" << std::endl;
|
2012-05-03 17:49:55 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
|
|
|
|
bool RsNxsSerialiser::serialiseNxsExtended(RsNxsExtended *item, void *data, uint32_t *size){
|
|
|
|
|
2012-05-03 17:49:55 -04:00
|
|
|
return false;
|
2012-05-01 16:52:07 -04:00
|
|
|
}
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
/*** deserialisation ***/
|
|
|
|
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
RsNxsGrp* RsNxsSerialiser::deserialNxsGrp(void *data, uint32_t *size){
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-24 18:38:59 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsGrp()" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(SERVICE_TYPE != getRsItemService(rstype)) ||
|
2012-05-21 18:07:43 -04:00
|
|
|
(RS_PKT_SUBTYPE_NXS_GRP != getRsItemSubType(rstype)))
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsGrp() FAIL wrong type" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*size < rssize) /* check size */
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsGrp() FAIL wrong size" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* not enough data */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the packet length */
|
|
|
|
*size = rssize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
RsNxsGrp* item = new RsNxsGrp(SERVICE_TYPE);
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-05-06 10:29:50 -04:00
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
|
2013-02-07 18:04:16 -05:00
|
|
|
ok &= getRawUInt8(data, *size, &offset, &(item->pos));
|
2012-05-21 18:07:43 -04:00
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
2012-05-24 18:38:59 -04:00
|
|
|
ok &= item->grp.GetTlv(data, *size, &offset);
|
2012-06-26 15:52:01 -04:00
|
|
|
ok &= item->meta.GetTlv(data, *size, &offset);
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
if (offset != rssize)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsGrp() FAIL size mismatch" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* error */
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsGrp() NOK" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
RsNxsMsg* RsNxsSerialiser::deserialNxsMsg(void *data, uint32_t *size){
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsMsg()" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(SERVICE_TYPE != getRsItemService(rstype)) ||
|
2012-05-21 18:07:43 -04:00
|
|
|
(RS_PKT_SUBTYPE_NXS_MSG != getRsItemSubType(rstype)))
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsMsg() FAIL wrong type" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*size < rssize) /* check size */
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsMsg() FAIL wrong size" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* not enough data */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the packet length */
|
|
|
|
*size = rssize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
RsNxsMsg* item = new RsNxsMsg(getRsItemService(rstype));
|
2012-05-06 10:29:50 -04:00
|
|
|
/* skip the header */
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
offset += 8;
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
|
2013-02-07 18:04:16 -05:00
|
|
|
ok &= getRawUInt8(data, *size, &offset, &(item->pos));
|
2012-05-21 18:07:43 -04:00
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_MSGID, item->msgId);
|
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
2012-06-26 15:52:01 -04:00
|
|
|
ok &= item->msg.GetTlv(data, *size, &offset);
|
|
|
|
ok &= item->meta.GetTlv(data, *size, &offset);
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
if (offset != rssize)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsMsg() FAIL size mismatch" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* error */
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-05-21 18:07:43 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsMsg() NOK" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncGrp* RsNxsSerialiser::deserialNxsSyncGrp(void *data, uint32_t *size){
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrp()" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(SERVICE_TYPE != getRsItemService(rstype)) ||
|
2012-06-07 16:43:12 -04:00
|
|
|
(RS_PKT_SUBTYPE_NXS_SYNC_GRP != getRsItemSubType(rstype)))
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrp() FAIL wrong type" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*size < rssize) /* check size */
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrp() FAIL wrong size" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* not enough data */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the packet length */
|
|
|
|
*size = rssize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncGrp* item = new RsNxsSyncGrp(getRsItemService(rstype));
|
2012-05-06 10:29:50 -04:00
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
|
2012-05-05 15:55:24 -04:00
|
|
|
ok &= getRawUInt8(data, *size, &offset, &(item->flag));
|
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->syncAge));
|
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_HASH_SHA1, item->syncHash);
|
|
|
|
|
|
|
|
if (offset != rssize)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrp() FAIL size mismatch" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* error */
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrp() NOK" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncGrpItem* RsNxsSerialiser::deserialNxsSyncGrpItem(void *data, uint32_t *size){
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrpItem()" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(SERVICE_TYPE != getRsItemService(rstype)) ||
|
2012-06-07 16:43:12 -04:00
|
|
|
(RS_PKT_SUBTYPE_NXS_SYNC_GRP_ITEM != getRsItemSubType(rstype)))
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrpItem() FAIL wrong type" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*size < rssize) /* check size */
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrpItem() FAIL wrong size" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* not enough data */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the packet length */
|
|
|
|
*size = rssize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncGrpItem* item = new RsNxsSyncGrpItem(SERVICE_TYPE);
|
2012-05-06 10:29:50 -04:00
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
|
2012-05-05 15:55:24 -04:00
|
|
|
ok &= getRawUInt8(data, *size, &offset, &(item->flag));
|
2012-05-24 18:38:59 -04:00
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
2012-06-26 15:52:01 -04:00
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->publishTs));
|
2013-06-04 17:00:43 -04:00
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_NAME, item->authorId);
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
if (offset != rssize)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrpItem() FAIL size mismatch" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* error */
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrpItem() NOK" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
RsNxsTransac* RsNxsSerialiser::deserialNxsTrans(void *data, uint32_t *size){
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsTrans()" << std::endl;
|
|
|
|
#endif
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(SERVICE_TYPE != getRsItemService(rstype)) ||
|
|
|
|
(RS_PKT_SUBTYPE_NXS_TRANS != getRsItemSubType(rstype)))
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsTrans() FAIL wrong type" << std::endl;
|
|
|
|
#endif
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*size < rssize) /* check size */
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncMsgItem( FAIL wrong size" << std::endl;
|
2012-06-05 10:46:18 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* not enough data */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the packet length */
|
|
|
|
*size = rssize;
|
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
RsNxsTransac* item = new RsNxsTransac(SERVICE_TYPE);
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
|
2012-06-05 10:46:18 -04:00
|
|
|
ok &= getRawUInt16(data, *size, &offset, &(item->transactFlag));
|
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->nItems));
|
2012-07-14 13:59:54 -04:00
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->timestamp));
|
2012-06-05 10:46:18 -04:00
|
|
|
|
|
|
|
if (offset != rssize)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsTrans() FAIL size mismatch" << std::endl;
|
|
|
|
#endif
|
|
|
|
/* error */
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsTrans() NOK" << std::endl;
|
|
|
|
#endif
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncMsgItem* RsNxsSerialiser::deserialNxsSyncMsgItem(void *data, uint32_t *size){
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncMsgItem()" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(SERVICE_TYPE != getRsItemService(rstype)) ||
|
2012-06-11 17:56:23 -04:00
|
|
|
(RS_PKT_SUBTYPE_NXS_SYNC_MSG_ITEM != getRsItemSubType(rstype)))
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncMsgItem() FAIL wrong type" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*size < rssize) /* check size */
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncMsgItem( FAIL wrong size" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* not enough data */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the packet length */
|
|
|
|
*size = rssize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncMsgItem* item = new RsNxsSyncMsgItem(getRsItemService(rstype));
|
2012-05-06 10:29:50 -04:00
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
|
2012-05-05 15:55:24 -04:00
|
|
|
ok &= getRawUInt8(data, *size, &offset, &(item->flag));
|
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
2012-05-24 18:38:59 -04:00
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_MSGID, item->msgId);
|
2013-06-04 17:00:43 -04:00
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_NAME, item->authorId);
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
if (offset != rssize)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncMsgItem() FAIL size mismatch" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* error */
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncMsgItem() NOK" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncMsg* RsNxsSerialiser::deserialNxsSyncMsg(void *data, uint32_t *size)
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrp()" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(SERVICE_TYPE != getRsItemService(rstype)) ||
|
2012-06-11 17:56:23 -04:00
|
|
|
(RS_PKT_SUBTYPE_NXS_SYNC_MSG != getRsItemSubType(rstype)))
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncMsg() FAIL wrong type" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*size < rssize) /* check size */
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncMsg() FAIL wrong size" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
return NULL; /* not enough data */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the packet length */
|
|
|
|
*size = rssize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
RsNxsSyncMsg* item = new RsNxsSyncMsg(getRsItemService(rstype));
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-05-06 10:29:50 -04:00
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
|
2012-05-05 15:55:24 -04:00
|
|
|
ok &= getRawUInt8(data, *size, &offset, &(item->flag));
|
|
|
|
ok &= getRawUInt32(data, *size, &offset, &(item->syncAge));
|
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_HASH_SHA1, item->syncHash);
|
|
|
|
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
|
|
|
|
|
|
|
if (offset != rssize)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncMsg() FAIL size mismatch" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
/* error */
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
#ifdef RSSERIAL_DEBUG
|
2012-06-11 17:56:23 -04:00
|
|
|
std::cerr << "RsNxsSerialiser::deserialNxsSyncMsg() NOK" << std::endl;
|
2012-05-05 15:55:24 -04:00
|
|
|
#endif
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
RsNxsExtended* RsNxsSerialiser::deserialNxsExtended(void *data, uint32_t *size){
|
2012-05-05 15:55:24 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** size functions ***/
|
|
|
|
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
uint32_t RsNxsSerialiser::sizeNxsMsg(RsNxsMsg *item)
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t s = 8; //header size
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
s += 4; // transaction number
|
2013-02-07 18:04:16 -05:00
|
|
|
s += 1; // pos
|
2012-05-21 18:07:43 -04:00
|
|
|
s += GetTlvStringSize(item->grpId);
|
|
|
|
s += GetTlvStringSize(item->msgId);
|
|
|
|
s += item->msg.TlvSize();
|
2012-06-26 15:52:01 -04:00
|
|
|
s += item->meta.TlvSize();
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
uint32_t RsNxsSerialiser::sizeNxsGrp(RsNxsGrp *item)
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
uint32_t s = 8; // header size
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
s += 4; // transaction number
|
2013-02-07 18:04:16 -05:00
|
|
|
s += 1; // pos
|
2012-05-21 18:07:43 -04:00
|
|
|
s += GetTlvStringSize(item->grpId);
|
|
|
|
s += item->grp.TlvSize();
|
2012-06-26 15:52:01 -04:00
|
|
|
s += item->meta.TlvSize();
|
2012-05-05 15:55:24 -04:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
uint32_t RsNxsSerialiser::sizeNxsSyncGrp(RsNxsSyncGrp *item)
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
uint32_t s = 8; // header size
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
s += 4; // transaction number
|
2012-05-05 15:55:24 -04:00
|
|
|
s += 1; // flag
|
|
|
|
s += 4; // sync age
|
|
|
|
s += GetTlvStringSize(item->syncHash);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
uint32_t RsNxsSerialiser::sizeNxsSyncGrpItem(RsNxsSyncGrpItem *item)
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
uint32_t s = 8; // header size
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
s += 4; // transaction number
|
2012-06-26 15:52:01 -04:00
|
|
|
s += 4; // publishTs
|
2012-05-05 15:55:24 -04:00
|
|
|
s += 1; // flag
|
2012-05-24 18:38:59 -04:00
|
|
|
s += GetTlvStringSize(item->grpId);
|
2013-06-04 17:00:43 -04:00
|
|
|
s += GetTlvStringSize(item->authorId);
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-05-06 10:29:50 -04:00
|
|
|
return s;
|
2012-05-05 15:55:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
uint32_t RsNxsSerialiser::sizeNxsSyncMsg(RsNxsSyncMsg *item)
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t s = 8;
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
s += 4; // transaction number
|
2012-05-05 15:55:24 -04:00
|
|
|
s += 1; // flag
|
|
|
|
s += 4; // age
|
|
|
|
s += GetTlvStringSize(item->grpId);
|
|
|
|
s += GetTlvStringSize(item->syncHash);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
uint32_t RsNxsSerialiser::sizeNxsSyncMsgItem(RsNxsSyncMsgItem *item)
|
2012-05-05 15:55:24 -04:00
|
|
|
{
|
|
|
|
uint32_t s = 8; // header size
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
s += 4; // transaction number
|
2012-05-05 15:55:24 -04:00
|
|
|
s += 1; // flag
|
|
|
|
s += GetTlvStringSize(item->grpId);
|
2012-05-24 18:38:59 -04:00
|
|
|
s += GetTlvStringSize(item->msgId);
|
2013-06-04 17:00:43 -04:00
|
|
|
s += GetTlvStringSize(item->authorId);
|
2012-05-05 15:55:24 -04:00
|
|
|
|
2012-05-06 10:29:50 -04:00
|
|
|
return s;
|
2012-05-05 15:55:24 -04:00
|
|
|
}
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
uint32_t RsNxsSerialiser::sizeNxsTrans(RsNxsTransac *item){
|
|
|
|
|
|
|
|
uint32_t s = 8; // header size
|
2012-06-07 16:43:12 -04:00
|
|
|
|
|
|
|
s += 4; // transaction number
|
2012-06-05 10:46:18 -04:00
|
|
|
s += 2; // flag
|
|
|
|
s += 4; // nMsgs
|
|
|
|
s += 4; // timeout
|
|
|
|
|
|
|
|
return s;
|
2012-05-05 15:55:24 -04:00
|
|
|
}
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-05-24 18:38:59 -04:00
|
|
|
uint32_t RsNxsSerialiser::sizeNxsExtended(RsNxsExtended *item){
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-07 18:04:16 -05:00
|
|
|
int RsNxsGrp::refcount = 0;
|
2012-05-06 10:29:50 -04:00
|
|
|
/** print and clear functions **/
|
2013-02-07 18:04:16 -05:00
|
|
|
int RsNxsMsg::refcount = 0;
|
2012-05-21 18:07:43 -04:00
|
|
|
void RsNxsMsg::clear()
|
2012-05-06 10:29:50 -04:00
|
|
|
{
|
2012-06-26 15:52:01 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
msg.TlvClear();
|
2012-06-26 15:52:01 -04:00
|
|
|
meta.TlvClear();
|
2012-05-06 10:29:50 -04:00
|
|
|
}
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
void RsNxsGrp::clear()
|
2012-05-06 10:29:50 -04:00
|
|
|
{
|
2012-05-21 18:07:43 -04:00
|
|
|
grpId.clear();
|
|
|
|
grp.TlvClear();
|
2012-06-26 15:52:01 -04:00
|
|
|
meta.TlvClear();
|
2012-05-06 10:29:50 -04:00
|
|
|
}
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
void RsNxsSyncGrp::clear()
|
2012-05-06 10:29:50 -04:00
|
|
|
{
|
|
|
|
flag = 0;
|
|
|
|
syncAge = 0;
|
|
|
|
syncHash.clear();
|
|
|
|
}
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
void RsNxsSyncMsg::clear()
|
2012-05-06 10:29:50 -04:00
|
|
|
{
|
|
|
|
grpId.clear();
|
|
|
|
flag = 0;
|
|
|
|
syncAge = 0;
|
|
|
|
syncHash.clear();
|
|
|
|
}
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
void RsNxsSyncGrpItem::clear()
|
2012-05-06 10:29:50 -04:00
|
|
|
{
|
|
|
|
flag = 0;
|
2012-06-26 15:52:01 -04:00
|
|
|
publishTs = 0;
|
2012-05-24 18:38:59 -04:00
|
|
|
grpId.clear();
|
2013-06-04 17:00:43 -04:00
|
|
|
authorId.clear();
|
2012-05-06 10:29:50 -04:00
|
|
|
}
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
void RsNxsSyncMsgItem::clear()
|
2012-05-06 10:29:50 -04:00
|
|
|
{
|
|
|
|
flag = 0;
|
2012-05-24 18:38:59 -04:00
|
|
|
msgId.clear();
|
|
|
|
grpId.clear();
|
2013-06-04 17:00:43 -04:00
|
|
|
authorId.clear();
|
2012-05-06 10:29:50 -04:00
|
|
|
}
|
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
void RsNxsTransac::clear(){
|
|
|
|
transactFlag = 0;
|
|
|
|
nItems = 0;
|
2012-07-14 13:59:54 -04:00
|
|
|
timestamp = 0;
|
2012-06-11 17:56:23 -04:00
|
|
|
transactionNumber = 0;
|
2012-06-05 10:46:18 -04:00
|
|
|
}
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
std::ostream& RsNxsSyncGrp::print(std::ostream &out, uint16_t indent)
|
2012-05-06 10:29:50 -04:00
|
|
|
{
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
printRsItemBase(out, "RsNxsSyncGrp", indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
uint16_t int_Indent = indent + 2;
|
|
|
|
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "Hash: " << syncHash << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "Sync Age: " << syncAge << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "flag" << flag << std::endl;
|
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
printRsItemEnd(out ,"RsNxsSyncGrp", indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
std::ostream& RsNxsExtended::print(std::ostream &out, uint16_t indent){
|
|
|
|
printRsItemBase(out, "RsNxsExtended", indent);
|
|
|
|
uint16_t int_Indent = indent + 2;
|
|
|
|
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "type: " << type << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
2012-06-26 15:52:01 -04:00
|
|
|
extData.print(out, int_Indent);
|
2012-05-21 18:07:43 -04:00
|
|
|
|
|
|
|
printRsItemEnd(out ,"RsNxsExtended", indent);
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
std::ostream& RsNxsSyncMsg::print(std::ostream &out, uint16_t indent)
|
2012-05-06 10:29:50 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
printRsItemBase(out, "RsNxsSyncMsg", indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
uint16_t int_Indent = indent + 2;
|
|
|
|
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "GrpId: " << grpId << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "syncAge: " << syncAge << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "syncHash: " << syncHash << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "flag: " << flag << std::endl;
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
printRsItemEnd(out, "RsNxsSyncMsg", indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
std::ostream& RsNxsSyncGrpItem::print(std::ostream &out, uint16_t indent)
|
2012-05-06 10:29:50 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
printRsItemBase(out, "RsNxsSyncGrpItem", indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
uint16_t int_Indent = indent + 2;
|
|
|
|
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "flag: " << flag << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
2012-05-24 18:38:59 -04:00
|
|
|
out << "grpId: " << grpId << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
2012-06-26 15:52:01 -04:00
|
|
|
out << "publishTs: " << publishTs << std::endl;
|
2013-06-04 17:00:43 -04:00
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "authorId: " << authorId << std::endl;
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
printRsItemEnd(out , "RsNxsSyncGrpItem", indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
std::ostream& RsNxsSyncMsgItem::print(std::ostream &out, uint16_t indent)
|
2012-05-06 10:29:50 -04:00
|
|
|
{
|
2012-06-11 17:56:23 -04:00
|
|
|
printRsItemBase(out, "RsNxsSyncMsgItem", indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
uint16_t int_Indent = indent + 2;
|
|
|
|
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "flag: " << flag << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "grpId: " << grpId << std::endl;
|
2012-05-24 18:38:59 -04:00
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "msgId: " << msgId << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
2013-06-04 17:00:43 -04:00
|
|
|
out << "authorId: " << authorId << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
printRsItemEnd(out ,"RsNxsSyncMsgItem", indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
std::ostream& RsNxsGrp::print(std::ostream &out, uint16_t indent){
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
printRsItemBase(out, "RsNxsGrp", indent);
|
|
|
|
uint16_t int_Indent = indent + 2;
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
out << "grpId: " << grpId << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
2012-06-26 15:52:01 -04:00
|
|
|
out << "grp: " << std::endl;
|
2013-02-07 18:04:16 -05:00
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "pos: " << pos << std::endl;
|
2012-06-26 15:52:01 -04:00
|
|
|
grp.print(out, int_Indent);
|
|
|
|
out << "meta: " << std::endl;
|
|
|
|
meta.print(out, int_Indent);
|
2012-05-21 18:07:43 -04:00
|
|
|
|
|
|
|
printRsItemEnd(out, "RsNxsGrp", indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
std::ostream& RsNxsMsg::print(std::ostream &out, uint16_t indent){
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
printRsItemBase(out, "RsNxsMsg", indent);
|
|
|
|
uint16_t int_Indent = indent + 2;
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
out << "msgId: " << msgId << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "grpId: " << grpId << std::endl;
|
2013-02-07 18:04:16 -05:00
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "pos: " << pos << std::endl;
|
2012-05-21 18:07:43 -04:00
|
|
|
printIndent(out , int_Indent);
|
2012-06-26 15:52:01 -04:00
|
|
|
out << "msg: " << std::endl;
|
|
|
|
msg.print(out, indent);
|
|
|
|
out << "meta: " << std::endl;
|
|
|
|
meta.print(out, int_Indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
printRsItemEnd(out ,"RsNxsMsg", indent);
|
2012-05-06 10:29:50 -04:00
|
|
|
return out;
|
|
|
|
}
|
2012-06-05 10:46:18 -04:00
|
|
|
|
|
|
|
|
|
|
|
std::ostream& RsNxsTransac::print(std::ostream &out, uint16_t indent){
|
|
|
|
|
|
|
|
printRsItemBase(out, "RsNxsTransac", indent);
|
|
|
|
uint16_t int_Indent = indent + 2;
|
|
|
|
|
|
|
|
out << "transactFlag: " << transactFlag << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
|
|
|
out << "nItems: " << nItems << std::endl;
|
|
|
|
printIndent(out , int_Indent);
|
2012-07-14 13:59:54 -04:00
|
|
|
out << "timeout: " << timestamp << std::endl;
|
2012-06-05 10:46:18 -04:00
|
|
|
printIndent(out , int_Indent);
|
2012-06-11 17:56:23 -04:00
|
|
|
out << "transactionNumber: " << transactionNumber << std::endl;
|
2012-06-05 10:46:18 -04:00
|
|
|
printIndent(out , int_Indent);
|
|
|
|
|
|
|
|
printRsItemEnd(out ,"RsNxsTransac", indent);
|
|
|
|
return out;
|
|
|
|
}
|