My Project: dht::Value Struct Reference

My Project 3.7.7 C++ Distributed Hash Table

Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
dht::Value Struct Reference

`#include <value.h>`

Collaboration diagram for dht::Value:
[legend]

## Classes
class | Filter
class | SerializableBase
class | Serializable

## Public Types
enum class | Field : int { None = 0 , Id , ValueType , OwnerPk , SeqNum , UserType , COUNT }
typedef uint64_t | Id

## Public Member Functions
template<typename T>
T | unpack ()
bool | isEncrypted () const
bool | isSigned () const
void | sign (const crypto::PrivateKey &key)
bool | checkSignature () const
std::shared_ptr< crypto::PublicKey > | getOwner () const
Value | encrypt (const crypto::PrivateKey &from, const crypto::PublicKey &to)
| Value (Id id)
| Value (ValueType::Id t, const Blob &data, Id id=INVALID_ID)
| Value (ValueType::Id t, Blob &&data, Id id=INVALID_ID)
| Value (ValueType::Id t, const uint8_t *dat_ptr, size_t dat_len, Id id=INVALID_ID)
template<typename Type>
| Value (ValueType::Id t, const Type &d, Id id=INVALID_ID)
template<typename Type>
| Value (const ValueType &t, const Type &d, Id id=INVALID_ID)
| Value (const Blob &userdata)
| Value (Blob &&userdata)
| Value (const uint8_t *dat_ptr, size_t dat_len)
| Value (Value &&o) noexcept
template<typename Type>
| Value (const Type &vs)
| Value (const msgpack::object &o)
bool | contentEquals (const Value &o) const
bool | operator== (const Value &o) const
bool | operator!= (const Value &o) const
void | setRecipient (const InfoHash &r)
void | setCypher (Blob &&c)
Blob | getToSign () const
Blob | getToEncrypt () const
std::string | toString () const
size_t | size () const
template<typename Packer>
void | msgpack_pack_to_sign (Packer &pk) const
template<typename Packer>
void | msgpack_pack_to_encrypt (Packer &pk) const
template<typename Packer>
void | msgpack_pack (Packer &pk) const
template<typename Packer>
void | msgpack_pack_fields (const std::set< Value::Field > &fields, Packer &pk) const
void | msgpack_unpack (const msgpack::object &o)
void | msgpack_unpack_body (const msgpack::object &o)
Blob | getPacked () const
void | msgpack_unpack_fields (const std::set< Value::Field > &fields, const msgpack::object &o, unsigned offset)
bool | isSignatureChecked () const
bool | isDecrypted () const
bool | checkSignature ()
Sp< Value > | decrypt (const crypto::PrivateKey &key)

## Static Public Member Functions
static Filter | AllFilter ()
static Filter | TypeFilter (const ValueType &t)
static Filter | TypeFilter (const ValueType::Id &tid)
static Filter | IdFilter (const Id id)
static Filter | RecipientFilter (const InfoHash &r)
static Filter | OwnerFilter (const crypto::PublicKey &pk)
static Filter | OwnerFilter (const InfoHash &pkh)
static Filter | SeqNumFilter (uint16_t seq_no)
static Filter | UserTypeFilter (std::string ut)
template<typename T, typename std::enable_if< std::is_base_of< SerializableBase, T >::value, T >::type * = nullptr>
static Value | pack (const T &obj)
template<typename T, typename std::enable_if<!std::is_base_of< SerializableBase, T >::value, T >::type * = nullptr>
static Value | pack (const T &obj)
template<typename T, typename std::enable_if< std::is_base_of< SerializableBase, T >::value, T >::type * = nullptr>
static T | unpack (const Value &v)
template<typename T, typename std::enable_if<!std::is_base_of< SerializableBase, T >::value, T >::type * = nullptr>
static T | unpack (const Value &v)

## Public Attributes
Id | id {INVALID_ID}
std::shared_ptr< crypto::PublicKey > | owner {}
InfoHash | recipient {}
ValueType::Id | type {ValueType::USER_DATA.id}
Blob | data {}
std::string | user_type {}
uint16_t | seq {0}
Blob | signature {}
Blob | cypher {}
unsigned | priority {0}

## Static Public Attributes
static const constexpr Id | INVALID_ID {0}

## Friends
OPENDHT_PUBLIC friend std::ostream & | operator<< (std::ostream &s, const Value &v)

## Detailed Description

A "value" is data potentially stored on the Dht, with some metadata.

It can be an IP:port announced for a service, a public key, or any kind of light user-defined data (recommended: less than 512 bytes).

Values are stored at a given InfoHash in the Dht, but also have a unique ID to distinguish between values stored at the same location.

Definition at line 149 of file value.h.

## Member Typedef Documentation

## ◆ Id

typedef uint64_t dht::Value::Id

Definition at line 162 of file value.h.

## Member Enumeration Documentation

## ◆ Field

enum class dht::Value::Field : int
| strong

Definition at line 151 of file value.h.

## Constructor & Destructor Documentation

## ◆ Value() [1/13]

dht::Value::Value | ( |  | ) |
| inline

Definition at line 386 of file value.h.

## ◆ Value() [2/13]

dht::Value::Value | ( | Id | id | ) |
| inline

Definition at line 388 of file value.h.

## ◆ Value() [3/13]

dht::Value::Value | ( | ValueType::Id | t,
|  | const Blob & | data,
|  | Id | id = INVALID_ID )
| inline

Generic constructor

Definition at line 393 of file value.h.

## ◆ Value() [4/13]

dht::Value::Value | ( | ValueType::Id | t,
|  | Blob && | data,
|  | Id | id = INVALID_ID )
| inline

Definition at line 398 of file value.h.

## ◆ Value() [5/13]

dht::Value::Value | ( | ValueType::Id | t,
|  | const uint8_t * | dat_ptr,
|  | size_t | dat_len,
|  | Id | id = INVALID_ID )
| inline

Definition at line 403 of file value.h.

## ◆ Value() [6/13]

template<typename Type>

dht::Value::Value | ( | ValueType::Id | t,
|  | const Type & | d,
|  | Id | id = INVALID_ID )
| inline

Definition at line 418 of file value.h.

## ◆ Value() [7/13]

template<typename Type>

dht::Value::Value | ( | const ValueType & | t,
|  | const Type & | d,
|  | Id | id = INVALID_ID )
| inline

Definition at line 425 of file value.h.

## ◆ Value() [8/13]

dht::Value::Value | ( | const Blob & | userdata | ) |
| inline

Custom user data constructor

Definition at line 432 of file value.h.

## ◆ Value() [9/13]

dht::Value::Value | ( | Blob && | userdata | ) |
| inline

Definition at line 435 of file value.h.

## ◆ Value() [10/13]

dht::Value::Value | ( | const uint8_t * | dat_ptr,
|  | size_t | dat_len )
| inline

Definition at line 438 of file value.h.

## ◆ Value() [11/13]

dht::Value::Value | ( | Value && | o | ) |
| inlinenoexcept

Definition at line 442 of file value.h.

## ◆ Value() [12/13]

template<typename Type>

dht::Value::Value | ( | const Type & | vs | ) |
| inline

Definition at line 456 of file value.h.

## ◆ Value() [13/13]

dht::Value::Value | ( | const msgpack::object & | o | ) |
| inline

Unpack a serialized value

Definition at line 463 of file value.h.

## Member Function Documentation

## ◆ AllFilter()

Filter dht::Value::AllFilter | ( |  | ) |
| inlinestatic

Definition at line 252 of file value.h.

## ◆ checkSignature()

bool dht::Value::checkSignature | ( |  | ) | const
| inline

Check that the value is signed and that the signature matches. If true, the owner field will contain the signer public key.

Definition at line 377 of file value.h.

## ◆ contentEquals()

bool dht::Value::contentEquals | ( | const Value & | o | ) | const
| inline

Returns true if value contents are equals (not considering the value ID)

Definition at line 468 of file value.h.

## ◆ encrypt()

Value dht::Value::encrypt | ( | const crypto::PrivateKey & | from,
|  | const crypto::PublicKey & | to )

Sign the value with from and returns the encrypted version for to.

## ◆ getOwner()

std::shared_ptr< crypto::PublicKey > dht::Value::getOwner | ( |  | ) | const
| inline

Definition at line 379 of file value.h.

## ◆ getPacked()

Blob dht::Value::getPacked | ( |  | ) | const
| inline

Definition at line 617 of file value.h.

## ◆ getToEncrypt()

Blob dht::Value::getToEncrypt | ( |  | ) | const
| inline

Pack part of the data to be encrypted

Definition at line 496 of file value.h.

## ◆ getToSign()

Blob dht::Value::getToSign | ( |  | ) | const
| inline

Pack part of the data to be signed (must always be done the same way)

Definition at line 485 of file value.h.

## ◆ IdFilter()

Filter dht::Value::IdFilter | ( | const Id | id | ) |
| inlinestatic

Definition at line 267 of file value.h.

## ◆ isDecrypted()

bool dht::Value::isDecrypted | ( |  | ) | const
| inline

Definition at line 675 of file value.h.

## ◆ isEncrypted()

bool dht::Value::isEncrypted | ( |  | ) | const
| inline

Definition at line 363 of file value.h.

## ◆ isSignatureChecked()

bool dht::Value::isSignatureChecked | ( |  | ) | const
| inline

Definition at line 674 of file value.h.

## ◆ isSigned()

bool dht::Value::isSigned | ( |  | ) | const
| inline

Definition at line 364 of file value.h.

## ◆ msgpack_pack()

template<typename Packer>

void dht::Value::msgpack_pack | ( | Packer & | pk | ) | const
| inline

Definition at line 574 of file value.h.

## ◆ msgpack_pack_fields()

template<typename Packer>

void dht::Value::msgpack_pack_fields | ( | const std::set< Value::Field > & | fields,
|  | Packer & | pk ) const
| inline

Definition at line 588 of file value.h.

## ◆ msgpack_pack_to_encrypt()

template<typename Packer>

void dht::Value::msgpack_pack_to_encrypt | ( | Packer & | pk | ) | const
| inline

Definition at line 556 of file value.h.

## ◆ msgpack_pack_to_sign()

template<typename Packer>

void dht::Value::msgpack_pack_to_sign | ( | Packer & | pk | ) | const
| inline

Definition at line 530 of file value.h.

## ◆ operator!=()

bool dht::Value::operator!= | ( | const Value & | o | ) | const
| inline

Definition at line 476 of file value.h.

## ◆ operator==()

bool dht::Value::operator== | ( | const Value & | o | ) | const
| inline

Definition at line 475 of file value.h.

## ◆ OwnerFilter() [1/2]

Filter dht::Value::OwnerFilter | ( | const crypto::PublicKey & | pk | ) |
| inlinestatic

Definition at line 281 of file value.h.

## ◆ OwnerFilter() [2/2]

Filter dht::Value::OwnerFilter | ( | const InfoHash & | pkh | ) |
| inlinestatic

Definition at line 283 of file value.h.

## ◆ pack() [1/2]

template<typename T, typename std::enable_if<!std::is_base_of< SerializableBase, T >::value, T >::type * = nullptr>

Value dht::Value::pack | ( | const T & | obj | ) |
| inlinestatic

Definition at line 338 of file value.h.

## ◆ pack() [2/2]

template<typename T, typename std::enable_if< std::is_base_of< SerializableBase, T >::value, T >::type * = nullptr>

Value dht::Value::pack | ( | const T & | obj | ) |
| inlinestatic

Definition at line 332 of file value.h.

## ◆ RecipientFilter()

Filter dht::Value::RecipientFilter | ( | const InfoHash & | r | ) |
| inlinestatic

Definition at line 274 of file value.h.

## ◆ SeqNumFilter()

Filter dht::Value::SeqNumFilter | ( | uint16_t | seq_no | ) |
| inlinestatic

Definition at line 290 of file value.h.

## ◆ setCypher()

void dht::Value::setCypher | ( | Blob && | c | ) |
| inline

Definition at line 480 of file value.h.

## ◆ setRecipient()

void dht::Value::setRecipient | ( | const InfoHash & | r | ) |
| inline

Definition at line 478 of file value.h.

## ◆ sign()

void dht::Value::sign | ( | const crypto::PrivateKey & | key | ) |

Sign the value using the provided private key. Afterward, checkSignature() will return true and owner will be set to the corresponding public key.

## ◆ size()

size_t dht::Value::size | ( |  | ) | const

Return the size in bytes used by this value in memory (minimum).

## ◆ toString()

std::string dht::Value::toString | ( |  | ) | const
| inline

Definition at line 507 of file value.h.

## ◆ TypeFilter() [1/2]

Filter dht::Value::TypeFilter | ( | const ValueType & | t | ) |
| inlinestatic

Definition at line 254 of file value.h.

## ◆ TypeFilter() [2/2]

Filter dht::Value::TypeFilter | ( | const ValueType::Id & | tid | ) |
| inlinestatic

Definition at line 260 of file value.h.

## ◆ unpack() [1/3]

template<typename T>

T dht::Value::unpack | ( |  | ) |
| inline

Definition at line 358 of file value.h.

## ◆ unpack() [2/3]

template<typename T, typename std::enable_if<!std::is_base_of< SerializableBase, T >::value, T >::type * = nullptr>

T dht::Value::unpack | ( | const Value & | v | ) |
| inlinestatic

Definition at line 352 of file value.h.

## ◆ unpack() [3/3]

template<typename T, typename std::enable_if< std::is_base_of< SerializableBase, T >::value, T >::type * = nullptr>

T dht::Value::unpack | ( | const Value & | v | ) |
| inlinestatic

Definition at line 344 of file value.h.

## ◆ UserTypeFilter()

Filter dht::Value::UserTypeFilter | ( | std::string | ut | ) |
| inlinestatic

Definition at line 297 of file value.h.

## Friends And Related Symbol Documentation

## ◆ operator<<

OPENDHT_PUBLIC friend std::ostream & operator<< | ( | std::ostream & | s,
|  | const Value & | v )
| friend

print value for debugging

## Member Data Documentation

## ◆ cypher

Blob dht::Value::cypher {}

Hold encrypted version of the data.

Definition at line 665 of file value.h.

## ◆ data

Blob dht::Value::data {}

Definition at line 645 of file value.h.

## ◆ id

Id dht::Value::id {INVALID_ID}

Definition at line 627 of file value.h.

## ◆ INVALID_ID

const constexpr Id dht::Value::INVALID_ID {0}
| staticconstexpr

Definition at line 163 of file value.h.

## ◆ owner

std::shared_ptr<crypto::PublicKey> dht::Value::owner {}

Public key of the signer.

Definition at line 632 of file value.h.

## ◆ priority

unsigned dht::Value::priority {0}

Priority of this value (used for push notifications) 0 = high priority 1 = normal priority

Definition at line 672 of file value.h.

## ◆ recipient

InfoHash dht::Value::recipient {}

Hash of the recipient (optional). Should only be present for encrypted values. Can optionally be present for signed values.

Definition at line 639 of file value.h.

## ◆ seq

uint16_t dht::Value::seq {0}

Sequence number to avoid replay attacks

Definition at line 655 of file value.h.

## ◆ signature

Blob dht::Value::signature {}

Optional signature.

Definition at line 660 of file value.h.

## ◆ type

ValueType::Id dht::Value::type {ValueType::USER_DATA.id}

Type of data.

Definition at line 644 of file value.h.

## ◆ user_type

std::string dht::Value::user_type {}

Custom user-defined type

Definition at line 650 of file value.h.

The documentation for this struct was generated from the following file:

- /home/noptrix/ba/blackarch/packages/opendht-c/src/opendht/include/opendht/value.h