73 if ((free_data) && (
op->cb_data) && (
op->heap))
86 bool free_data =
true;
89 free_data =
op->cb (
op->cb_data, NULL);
101 block_expiration_time,
102 const uint8_t *block_data,
103 size_t block_data_len,
106 unsigned int put_path_len_in,
107 unsigned int *put_path_len_out,
116 *put_path_len_out = put_path_len_in;
118 if (NULL != trunc_peer)
120 *trunc_peer_out = *trunc_peer;
124 unsigned int failure_offset;
129 block_expiration_time,
135 if (0 != failure_offset)
139 *trunc_peer_out = put_path_out[failure_offset - 1].
pred;
140 put_path_out = &put_path_out[failure_offset];
141 *put_path_len_out = put_path_len_in - failure_offset;
161 "Discarding message that is too large due to tracking\n");
172 *put_path_len_out = 0;
183 "Truncating path that is too large due\n");
196 *trunc_peer_out = put_path_out[*put_path_len_out - ppl - 1].
pred;
197 put_path_out = &put_path_out[*put_path_len_out - ppl];
198 *put_path_len_out = ppl;
218 free_data =
op->cb (
op->cb_data, sig);
238 .purpose.size = htonl (
sizeof (hs)),
256 return cb (cb_data, &sig);
265 if (cb_data_size > 0)
280 if (NULL ==
op->sign_op)
286 return (cb_data_size > 0);
300 unsigned int put_path_len;
303 "Signing PUT PATH %u => %s\n",
306 memcpy (msg_data->
sig,
sig, sizeof (*
sig));
310 free_data = msg_data->
cb (msg_data->
cb_data,
312 sig? msg_data->
ppm : NULL);
316 if ((free_data) && (msg_data->
cb_data) && (msg_data->
heap))
336 const uint8_t *block_data,
337 size_t block_data_len,
339 unsigned int put_path_len,
341 uint32_t desired_replication_level,
367 ppm->
key = *block_key;
387 void *tgt = &pp[put_path_len];
401 void *tgt = &pp[put_path_len];
403 if (0 == put_path_len)
410 pred = &pp[put_path_len - 1].
pred;
421 msg_data.
heap =
false;
426 block_expiration_time,
431 &msg_data) && (cb_data_size > 0);
439 ((
size_t) msg_data.
ppm) + ((size_t) tgt) - ((size_t) ppm));
443 if (cb_data_size > 0)
446 msg_data.
heap =
true;
451 msg_data.
heap =
false;
457 block_expiration_time,
462 &msg_data) && (cb_data_size > 0);
466 return cb (cb_data, msize, ppm);
#define DHT_BLOOM_SIZE
Size of the bloom filter the DHT uses to filter peers.
bool GDS_helper_make_put_message(struct PeerPutMessage *ppm, size_t msize, const struct GNUNET_CRYPTO_EddsaPrivateKey *sk, const struct GNUNET_PeerIdentity *target, const struct GNUNET_HashCode *target_hash, const struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *block_key, enum GNUNET_DHT_RouteOption ro, enum GNUNET_BLOCK_Type block_type, struct GNUNET_TIME_Absolute block_expiration_time, const uint8_t *block_data, size_t block_data_len, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_len, size_t hop_count, uint32_t desired_replication_level, const struct GNUNET_PeerIdentity *trunc_peer, GDS_HelperMsgCallback cb, size_t cb_data_size, void *cb_data)
static void cleanup_helper_operation(struct GDS_HelperOperation *op, bool free_data)
bool GDS_helper_sign_path(const void *data, size_t data_size, const struct GNUNET_CRYPTO_EddsaPrivateKey *sk, struct GNUNET_TIME_Absolute exp_time, const struct GNUNET_PeerIdentity *pred, const struct GNUNET_PeerIdentity *succ, GDS_HelperCallback cb, size_t cb_data_size, void *cb_data)
Sign that we are routing a message from pred to succ.
static struct GDS_HelperOperation * op_head
enum GNUNET_GenericReturnValue GDS_helper_put_message_get_size(size_t *msize_out, const struct GNUNET_PeerIdentity *my_identity, enum GNUNET_DHT_RouteOption ro_in, enum GNUNET_DHT_RouteOption *ro_out, struct GNUNET_TIME_Absolute block_expiration_time, const uint8_t *block_data, size_t block_data_len, const struct GNUNET_DHT_PathElement *put_path_in, unsigned int put_path_len_in, unsigned int *put_path_len_out, const struct GNUNET_PeerIdentity *trunc_peer, struct GNUNET_PeerIdentity *trunc_peer_out, bool *truncated)
static bool cb_path_signed(void *cls, const struct GNUNET_CRYPTO_EddsaSignature *sig)
static struct GDS_HelperOperation * op_tail
void GDS_helper_cleanup_operations(void)
static void cb_sign_result(void *cls, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig)
Helper functions for DHT.
struct GNUNET_PILS_Handle * GDS_pils
Handle for the pils service.
bool(* GDS_HelperMsgCallback)(void *cls, size_t msize, struct PeerPutMessage *ppm)
bool(* GDS_HelperCallback)(void *cls, const struct GNUNET_CRYPTO_EddsaSignature *sig)
static struct GNUNET_ARM_Operation * op
Current operation.
static unsigned int block_type
The type of the query.
static char * data
The data to insert into the dht.
static size_t data_size
Number of bytes in data.
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
void GNUNET_PILS_cancel(struct GNUNET_PILS_Operation *op)
Cancel request.
struct GNUNET_PILS_Operation * GNUNET_PILS_sign_by_peer_identity(struct GNUNET_PILS_Handle *handle, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, GNUNET_PILS_SignResultCallback cb, void *cb_cls)
Sign data with the peer id.
#define GNUNET_SIGNATURE_PURPOSE_DHT_HOP
Signature by which a peer affirms that it forwarded a message in the DHT.
Functions related to time.
bool GNUNET_CONTAINER_bloomfilter_test(const struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Test if an element is in the filter.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_bloomfilter_get_raw_data(const struct GNUNET_CONTAINER_BloomFilter *bf, char *data, size_t size)
Copy the raw data of this Bloom filter into the given data array.
#define GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE
What is the maximum size for encrypted messages? Note that this number imposes a clear limit on the m...
#define GNUNET_CRYPTO_eddsa_sign(priv, ps, sig)
EdDSA sign a given block.
GNUNET_DHT_RouteOption
Options for routing.
unsigned int GNUNET_DHT_verify_path(const void *data, size_t data_size, struct GNUNET_TIME_Absolute exp_time, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_len, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_len, const struct GNUNET_PeerIdentity *me)
Verify signatures on a path consisting of put_path and get_path in reverse order (starting at the las...
@ GNUNET_DHT_RO_TRUNCATED
Flag set if the path was truncated.
@ GNUNET_DHT_RO_RECORD_ROUTE
We should keep track of the route that the message took in the P2P network.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
#define GNUNET_B2S(obj)
Convert a fixed-sized object to a string using GNUNET_b2s().
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
#define GNUNET_MESSAGE_TYPE_DHT_P2P_PUT
Peer is storing data in DHT.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
struct GNUNET_CRYPTO_EddsaSignature * sig
struct PeerPutMessage * ppm
struct GDS_HelperOperation * next
struct GNUNET_PILS_Operation * sign_op
struct GDS_HelperOperation * prev
Private ECC key encoded for transmission.
an ECC signature using EdDSA.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
Message signed by a peer when doing path tracking.
struct GNUNET_CRYPTO_SignaturePurpose purpose
Must be GNUNET_SIGNATURE_PURPOSE_DHT_HOP.
struct GNUNET_HashCode h_data
Hash over the payload of the block.
struct GNUNET_PeerIdentity pred
Previous hop the message was received from.
struct GNUNET_PeerIdentity succ
Next hop the message was forwarded to.
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...
struct GNUNET_PeerIdentity pred
Previous peer on the path (matches "pred" in the signed field).
struct GNUNET_CRYPTO_EddsaSignature sig
Signature affirming the hop of type GNUNET_SIGNATURE_PURPOSE_DHT_HOP.
The identity of the host (wraps the signing key of the peer).
Time for absolute times used by GNUnet, in microseconds.
uint16_t desired_replication_level
Replication level for this message.
uint16_t hop_count
Hop count.
uint32_t type
Content type, must not be zero.
char bloomfilter[128]
Bloomfilter (for peer identities) to stop circular routes.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_P2P_PUT.
struct GNUNET_HashCode key
The key we are storing under.
uint16_t options
Processing options.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the content expire?
uint16_t put_path_length
Length of the PUT path that follows (if tracked).