mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-15 01:17:16 -05:00
improved type definition for GRouter item flags (simplified changed from PR~1697)
This commit is contained in:
parent
e5d8600f25
commit
28ec7f5fb2
@ -108,7 +108,7 @@ void RsGRouterGenericDataItem::serial_process(RsGenericSerializer::SerializeJob
|
|||||||
|
|
||||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,signature,"signature") ;
|
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,signature,"signature") ;
|
||||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,duplication_factor,"duplication_factor") ;
|
RsTypeSerializer::serial_process<uint32_t>(j,ctx,duplication_factor,"duplication_factor") ;
|
||||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,flags,"flags") ;
|
RS_SERIAL_PROCESS(flags);
|
||||||
|
|
||||||
if(j == RsGenericSerializer::DESERIALIZE) // make sure the duplication factor is not altered by friends. In the worst case, the item will duplicate a bit more.
|
if(j == RsGenericSerializer::DESERIALIZE) // make sure the duplication factor is not altered by friends. In the worst case, the item will duplicate a bit more.
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ void RsGRouterGenericDataItem::serial_process(RsGenericSerializer::SerializeJob
|
|||||||
void RsGRouterSignedReceiptItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
void RsGRouterSignedReceiptItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||||
{
|
{
|
||||||
RsTypeSerializer::serial_process<uint64_t> (j,ctx,routing_id,"routing_id") ;
|
RsTypeSerializer::serial_process<uint64_t> (j,ctx,routing_id,"routing_id") ;
|
||||||
RsTypeSerializer::serial_process<uint32_t> (j,ctx,flags,"flags") ;
|
RS_SERIAL_PROCESS(flags);
|
||||||
RsTypeSerializer::serial_process (j,ctx,destination_key,"destination_key") ;
|
RsTypeSerializer::serial_process (j,ctx,destination_key,"destination_key") ;
|
||||||
RsTypeSerializer::serial_process<uint32_t> (j,ctx,service_id,"service_id") ;
|
RsTypeSerializer::serial_process<uint32_t> (j,ctx,service_id,"service_id") ;
|
||||||
RsTypeSerializer::serial_process (j,ctx,data_hash,"data_hash") ;
|
RsTypeSerializer::serial_process (j,ctx,data_hash,"data_hash") ;
|
||||||
@ -269,3 +269,4 @@ RsGRouterSignedReceiptItem *RsGRouterSignedReceiptItem::duplicate() const
|
|||||||
return item ;
|
return item ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsGRouterAbstractMsgItem::~RsGRouterAbstractMsgItem() = default;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "serialiser/rstlvkeys.h"
|
#include "serialiser/rstlvkeys.h"
|
||||||
#include "rsitems/rsserviceids.h"
|
#include "rsitems/rsserviceids.h"
|
||||||
#include "retroshare/rstypes.h"
|
#include "retroshare/rstypes.h"
|
||||||
|
#include "retroshare/rsflags.h"
|
||||||
#include "retroshare/rsgrouter.h"
|
#include "retroshare/rsgrouter.h"
|
||||||
#include "groutermatrix.h"
|
#include "groutermatrix.h"
|
||||||
|
|
||||||
@ -83,40 +83,59 @@ class RsGRouterNonCopyableObject
|
|||||||
// and routing ID. Sub-items are responsible for providing the serialised data to be signed for
|
// and routing ID. Sub-items are responsible for providing the serialised data to be signed for
|
||||||
// both signing and checking.
|
// both signing and checking.
|
||||||
|
|
||||||
class RsGRouterAbstractMsgItem: public RsGRouterItem
|
enum class RsGRouterItemFlags : uint32_t
|
||||||
{
|
{
|
||||||
public:
|
NONE = 0x0,
|
||||||
explicit RsGRouterAbstractMsgItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype), flags(0) {}
|
ENCRYPTED = 0x1,
|
||||||
virtual ~RsGRouterAbstractMsgItem() {}
|
SERVICE_UNKNOWN = 0x2
|
||||||
|
};
|
||||||
|
RS_REGISTER_ENUM_FLAGS_TYPE(RsGRouterItemFlags)
|
||||||
|
|
||||||
|
struct RsGRouterAbstractMsgItem: RsGRouterItem
|
||||||
|
{
|
||||||
|
explicit RsGRouterAbstractMsgItem(uint8_t pkt_subtype):
|
||||||
|
RsGRouterItem(pkt_subtype), flags(RsGRouterItemFlags::NONE) {}
|
||||||
|
|
||||||
GRouterMsgPropagationId routing_id ;
|
GRouterMsgPropagationId routing_id ;
|
||||||
GRouterKeyId destination_key ;
|
GRouterKeyId destination_key ;
|
||||||
GRouterServiceId service_id ;
|
GRouterServiceId service_id ;
|
||||||
RsTlvKeySignature signature ; // signs mid+destination_key+state
|
RsTlvKeySignature signature ; // signs mid+destination_key+state
|
||||||
uint32_t flags ; // packet was delivered, not delivered, bounced, etc
|
|
||||||
|
/// packet was delivered, not delivered, bounced, etc
|
||||||
|
RsGRouterItemFlags flags;
|
||||||
|
|
||||||
|
~RsGRouterAbstractMsgItem();
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsGRouterGenericDataItem: public RsGRouterAbstractMsgItem, public RsGRouterNonCopyableObject
|
class RsGRouterGenericDataItem:
|
||||||
|
public RsGRouterAbstractMsgItem, public RsGRouterNonCopyableObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsGRouterGenericDataItem() : RsGRouterAbstractMsgItem(RS_PKT_SUBTYPE_GROUTER_DATA), data_size(0), data_bytes(NULL), duplication_factor(0) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
|
RsGRouterGenericDataItem():
|
||||||
virtual ~RsGRouterGenericDataItem() { clear() ; }
|
RsGRouterAbstractMsgItem(RS_PKT_SUBTYPE_GROUTER_DATA),
|
||||||
|
data_size(0), data_bytes(nullptr), duplication_factor(0)
|
||||||
|
{ setPriorityLevel(QOS_PRIORITY_RS_GROUTER); }
|
||||||
|
|
||||||
|
virtual ~RsGRouterGenericDataItem() { clear(); }
|
||||||
virtual void clear()
|
virtual void clear()
|
||||||
{
|
{
|
||||||
free(data_bytes);
|
free(data_bytes);
|
||||||
data_bytes=NULL;
|
data_bytes = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
virtual void serial_process(
|
||||||
|
RsGenericSerializer::SerializeJob j,
|
||||||
|
RsGenericSerializer::SerializeContext& ctx );
|
||||||
|
|
||||||
RsGRouterGenericDataItem *duplicate() const;
|
RsGRouterGenericDataItem *duplicate() const;
|
||||||
|
|
||||||
// packet data
|
/// packet data
|
||||||
//
|
|
||||||
uint32_t data_size;
|
uint32_t data_size;
|
||||||
uint8_t* data_bytes;
|
uint8_t* data_bytes;
|
||||||
uint32_t duplication_factor ; // number of duplicates allowed. Should be capped at each de-serialise operation!
|
|
||||||
|
/** number of duplicates allowed. Should be capped at each de-serialise
|
||||||
|
* operation! */
|
||||||
|
uint32_t duplication_factor;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsGRouterSignedReceiptItem: public RsGRouterAbstractMsgItem
|
class RsGRouterSignedReceiptItem: public RsGRouterAbstractMsgItem
|
||||||
|
Loading…
Reference in New Issue
Block a user