49 #define LOG_TRAFFIC(kind, ...) GNUNET_log_from (kind, "dht-traffic", \ 55 #define SANITY_CHECKS 1 60 #define MAX_BUCKETS sizeof(struct GNUNET_HashCode) * 8 65 #define DEFAULT_BUCKET_SIZE 8 70 #define FIND_PEER_REPLICATION_LEVEL 4 75 #define MAXIMUM_REPLICATION_LEVEL 16 80 #define MAXIMUM_PENDING_PER_PEER 64 85 #define DHT_MINIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply ( \ 86 GNUNET_TIME_UNIT_SECONDS, 30) 91 #define DHT_MAXIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply ( \ 92 GNUNET_TIME_UNIT_MINUTES, 10) 97 #define GET_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) 528 if ((0 == strength) &&
547 if ((NULL != ci->
oh) &&
555 if ((NULL != ci->
sh) &&
632 "Adding known peer (%s) to bloomfilter for FIND PEER\n",
653 find_peer_task = NULL;
793 struct PeerInfo *to_remove = internal_cls;
797 if (NULL == to_remove)
814 find_peer_task = NULL;
841 uint32_t target_replication)
843 uint32_t random_value;
844 uint32_t forward_count;
865 + ((float) (target_replication - 1.0)
868 forward_count = (uint32_t) target_value;
870 target_value = target_value - forward_count;
873 if (random_value < (target_value * UINT32_MAX))
875 return forward_count;
917 return (
unsigned int) -1;
921 msb = (512 - bucket) << (32 - 9);
932 lsb |= (1 << (bucket + 32 - 9 - i));
969 if ((NULL != bloom) &&
979 if (other_bits > bits)
981 if (other_bits == bits)
1014 unsigned int selected;
1017 unsigned int smallest_distance;
1023 smallest_distance = UINT_MAX;
1031 if ((NULL == bloom) ||
1038 if (dist < smallest_distance)
1041 smallest_distance = dist;
1047 "Excluded peer `%s' due to BF match in greedy routing for %s\n",
1052 "# Peers excluded from routing due to Bloomfilter"),
1057 if (dist < smallest_distance)
1060 smallest_distance = dist;
1074 "Selected peer `%s' in greedy routing for %s\n",
1088 if ((NULL != bloom) &&
1096 "# Peers excluded from routing due to Bloomfilter"),
1099 "Excluded peer `%s' due to BF match in random routing for %s\n",
1125 if ((bloom != NULL) &&
1132 if (0 == selected--)
1135 "Selected peer `%s' in random routing for %s\n",
1164 uint32_t target_replication,
1174 target_replication);
1182 for (off = 0; off <
ret; off++)
1189 rtargets[off] = nxt;
1197 "Selected %u/%u peers at hop %u for %s (target was %u)\n",
1200 (
unsigned int) hop_count,
1209 *targets = rtargets;
1211 "Forwarding query `%s' to %u peers (goal was %u peers)\n",
1252 unsigned int target_count;
1260 unsigned int skip_count;
1264 "Adding myself (%s) to PUT bloomfilter for %s\n",
1277 desired_replication_level,
1279 if (0 == target_count)
1282 "Routing PUT for %s terminates after %u hops at %s\n",
1284 (
unsigned int) hop_count,
1292 put_path_length = 0;
1304 "# PUT messages queued for transmission"),
1308 for (i = 0; i < target_count; i++)
1310 target = targets[i];
1316 "# P2P messages dropped due to full queue"),
1323 "Routing PUT for %s after %u hops to %s\n",
1325 (
unsigned int) hop_count,
1330 ppm->
options = htonl (options);
1331 ppm->
type = htonl (type);
1387 unsigned int target_count;
1394 size_t reply_bf_size;
1396 unsigned int skip_count;
1407 desired_replication_level,
1410 "Adding myself (%s) to GET bloomfilter for %s\n",
1415 if (0 == target_count)
1418 "Routing GET for %s terminates after %u hops at %s\n",
1420 (
unsigned int) hop_count,
1435 msize = xquery_size + reply_bf_size;
1445 "# GET messages queued for transmission"),
1450 for (
unsigned int i = 0; i < target_count; i++)
1452 target = targets[i];
1458 "# P2P messages dropped due to full queue"),
1464 "Routing GET for %s after %u hops to %s\n",
1466 (
unsigned int) hop_count,
1471 pgm->
options = htonl (options);
1472 pgm->
type = htonl (type);
1485 xq = (
char *) &pgm[1];
1524 unsigned int get_path_length,
1553 "No matching peer for reply for key %s\n",
1562 "# P2P messages dropped due to full queue"),
1566 "Peer queue full, ignoring reply for key %s\n",
1572 "Forwarding reply for key %s to peer %s\n",
1577 (
"# RESULT messages queued for transmission"), 1,
1582 prm->
type = htonl (type);
1614 "CORE called, I am %s\n",
1669 size_t payload_size;
1696 payload = &put_path[putlen];
1697 options = ntohl (put->
options);
1702 "PUT for `%s' from %s\n",
1714 "R5N PUT %s: %s->%s (%u, %u=>%u, PP: %s)\n",
1735 if (0 != memcmp (&test_key,
1743 "PUT with key `%s' for block with key %s\n",
1799 for (
unsigned int i = 0; i <= putlen; i++)
1801 for (
unsigned int j = 0; j < i; j++)
1815 pp[putlen] = *peer->
id;
1888 unsigned int choice;
1924 "# FIND PEER requests ignored due to Bloomfilter"),
1933 "# FIND PEER requests ignored due to lack of HELLO"),
1953 peer = bucket->
head;
1967 peer = bucket->
head;
1970 while ((NULL == hello) ||
2015 unsigned int get_path_length,
2026 "Found local result for %s (PP: %s)\n",
2034 put_path_length, put_path,
2035 get_path_length, get_path,
2051 uint32_t xquery_size;
2055 msize = ntohs (get->header.size);
2056 xquery_size = ntohl (get->xquery_size);
2077 uint32_t xquery_size;
2078 size_t reply_bf_size;
2089 msize = ntohs (get->header.size);
2090 xquery_size = ntohl (get->xquery_size);
2091 reply_bf_size = msize - (
sizeof(
struct PeerGetMessage) + xquery_size);
2092 type = ntohl (get->type);
2093 options = ntohl (get->options);
2094 xquery = (
const char *) &
get[1];
2109 "R5N GET %s: %s->%s (%u, %u=>%u) xq: %.*s\n",
2113 ntohl (get->hop_count),
2118 ntohl (get->xquery_size),
2147 &xquery[xquery_size],
2153 "GET for %s at %s after %u hops\n",
2156 (
unsigned int) ntohl (get->hop_count));
2166 "# P2P FIND PEER requests processed"),
2207 get->desired_replication_level),
2208 ntohl (get->hop_count),
2218 ntohl (get->hop_count),
2219 ntohl (get->desired_replication_level),
2240 uint32_t get_path_length;
2280 unsigned int get_path_length,
2320 get_path_length + put_path_length,
2353 uint32_t get_path_length;
2375 type = ntohl (prm->
type);
2376 data = (
const void *) &get_path[get_path_length];
2379 + put_path_length) *
sizeof(
struct 2401 "R5N RESULT %s: %s->%s (GP: %s, PP: %s)\n",
2424 if (data_size != ntohs (h->
size))
2446 for (
unsigned int i = 0; i <= get_path_length; i++)
2447 if (0 == memcmp (&get_path[i],
2470 xget_path[get_path_length] = *peer->
id;
2474 get_path_length + 1,
2508 unsigned long long temp_config_num;
2513 "DISABLE_TRY_CONNECT");
2534 if (NULL == core_api)
2550 if (NULL == core_api)
2557 all_connected_peers = NULL;
2562 all_desired_peers = NULL;
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Block does not match query (invalid result)
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init(const char *data, size_t size, unsigned int k)
Create a Bloom filter from raw bits.
struct GNUNET_PeerIdentity * GDS_NEIGHBOURS_get_id()
Get the ID of the local node.
char bloomfilter[128]
Bloomfilter (for peer identities) to stop circular routes.
static unsigned int closest_bucket
The lowest currently used bucket, initially 0 (for 0-bits matching bucket).
int GNUNET_HELLO_get_id(const struct GNUNET_HELLO_Message *hello, struct GNUNET_PeerIdentity *peer)
Get the peer identity from a HELLO message.
uint32_t type
Content type.
static unsigned int get_distance(const struct GNUNET_HashCode *target, const struct GNUNET_HashCode *have)
Compute the distance between have and target as a 32-bit value.
struct GNUNET_MessageHeader * GDS_my_hello
Our HELLO.
uint32_t type
Desired content type.
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
We should keep track of the route that the message took in the P2P network.
A HELLO message is used to exchange information about transports with other peers.
#define DHT_MINIMUM_FIND_PEER_INTERVAL
How long at least to wait before sending another find peer request.
static struct PeerBucket k_buckets[sizeof(struct GNUNET_HashCode) *8]
The buckets.
Entry in linked list for all offer-HELLO requests.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
struct PeerInfo * prev
Prev peer entry (DLL)
void GNUNET_CONTAINER_bloomfilter_add(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Add an element to the filter.
static int cache_results
Do we cache all results that we are routing in the local datacache?
uint64_t rel_value_us
The actual value.
static struct PeerInfo * select_peer(const struct GNUNET_HashCode *key, const struct GNUNET_CONTAINER_BloomFilter *bloom, uint32_t hops)
Select a peer from the routing table that would be a good routing destination for sending a message f...
uint32_t put_path_length
Length of the PUT path that follows (if tracked).
struct PeerInfo * next
Next peer entry (DLL)
uint32_t hop_count
Hop count.
void GNUNET_SERVICE_resume(struct GNUNET_SERVICE_Handle *sh)
Resume accepting connections from the listen socket.
static int check_dht_p2p_result(void *cls, const struct PeerResultMessage *prm)
Check validity of p2p result message.
void GDS_NEIGHBOURS_done()
Shutdown neighbours subsystem.
Context for the core service connection.
int GNUNET_CRYPTO_hash_get_bit_rtl(const struct GNUNET_HashCode *code, unsigned int bit)
Obtain a bit from a hashcode.
#define MAXIMUM_PENDING_PER_PEER
Maximum allowed number of pending messages per peer.
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
static void update_connect_preferences()
Update our preferences for connectivity as given to ATS.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
static void handle_dht_p2p_get(void *cls, const struct PeerGetMessage *get)
Core handler for p2p get requests.
unsigned int GNUNET_CRYPTO_hash_matching_bits(const struct GNUNET_HashCode *first, const struct GNUNET_HashCode *second)
Determine how many low order bits match in two struct GNUNET_HashCodes.
#define DHT_BLOOM_SIZE
Size of the bloom filter the DHT uses to filter peers.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
static size_t data_size
Number of bytes in data.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_CONSTANTS_BLOOMFILTER_K
K-value that must be used for the bloom filters in 'GET' queries.
static void handle_find_peer(const struct GNUNET_PeerIdentity *sender, const struct GNUNET_HashCode *key, struct GNUNET_BLOCK_Group *bg)
We have received a FIND PEER request.
static struct GNUNET_SCHEDULER_Task * find_peer_task
Task that sends FIND PEER requests.
uint32_t put_path_length
Length of the PUT path that follows (if tracked).
struct GNUNET_SERVICE_Handle * GDS_service
Handle for the service.
struct PeerInfo * head
Head of DLL.
static int find_bucket(const struct GNUNET_HashCode *hc)
Find the optimal bucket for this key.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
Block does not match xquery (valid result, not relevant for the request)
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
uint32_t get_path_length
Length of the GET path that follows (if tracked).
#define GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION
After how long do we expire an address in a HELLO that we just validated? This value is also used for...
unsigned int peers_size
Number of peers in the bucket.
static unsigned int get_forward_count(uint32_t hop_count, uint32_t target_replication)
To how many peers should we (on average) forward the request to obtain the desired target_replication...
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_HashCode phash
Hash of id.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void core_init(void *cls, const struct GNUNET_PeerIdentity *identity)
To be called on core init/fail.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
uint32_t options
Processing options.
struct GNUNET_HashCode key
The key we are looking for.
char bloomfilter[128]
Bloomfilter (for peer identities) to stop circular routes.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GDS_CLIENTS_process_get(uint32_t options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, const struct GNUNET_HashCode *key)
Check if some client is monitoring GET messages and notify them in that case.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
#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_strdup(a)
Wrapper around GNUNET_xstrdup_.
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
GNUnet DHT integration with peerinfo.
void GDS_CLIENTS_process_put(uint32_t options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
Check if some client is monitoring PUT messages and notify them in that case.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static unsigned int newly_found_peers
How many peers have we added since we sent out our last find peer request?
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define FIND_PEER_REPLICATION_LEVEL
Desired replication level for FIND PEER requests.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_BLOCK_get_key(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, struct GNUNET_HashCode *key)
Function called to obtain the key for a block.
struct GNUNET_HashCode my_identity_hash
Hash of the identity of this peer.
struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest(struct GNUNET_ATS_ConnectivityHandle *ch, const struct GNUNET_PeerIdentity *peer, uint32_t strength)
We would like to receive address suggestions for a peer.
static int add_known_to_bloom(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Add each of the peers we already know to the bloom filter of the request so that we don't get duplica...
#define DHT_MAXIMUM_FIND_PEER_INTERVAL
How long at most to wait before sending another find peer request.
uint32_t desired_replication_level
Desired replication level for this request.
static int disable_try_connect
Option for testing that disables the 'connect' function of the DHT.
struct GNUNET_BLOCK_Context * GDS_block_context
Our handle to the BLOCK library.
static int update_desire_strength(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Function called for each peer in all_desired_peers during update_connect_preferences() if we have rea...
int peer_bucket
Which bucket is this peer in?
Flag given to monitors if this was the last hop for a GET/PUT.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
static int free_connect_info(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Function called for all entries in all_desired_peers to clean up.
struct GNUNET_HashCode key
The key we are storing under.
This is a 'FIND-PEER' request, so approximate results are fine.
struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Handle to active HELLO offer operation, or NULL.
static char * value
Value of the record to add/remove.
#define MAX_BUCKETS
How many buckets will we allow total.
int GNUNET_CONTAINER_bloomfilter_test(const struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Test if an element is in the filter.
Valid result, but suppressed because it is a duplicate.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Information about a peer that we would like to connect to.
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
char * GNUNET_STRINGS_pp2s(const struct GNUNET_PeerIdentity *pids, unsigned int num_pids)
Convert a peer path to a human-readable string.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
enum GNUNET_BLOCK_EvaluationResult GNUNET_BLOCK_evaluate(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, enum GNUNET_BLOCK_EvaluationOptions eo, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size, const void *reply_block, size_t reply_block_size)
Function called to validate a reply or a request.
void GDS_DATACACHE_handle_put(struct GNUNET_TIME_Absolute expiration, const struct GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, enum GNUNET_BLOCK_Type type, size_t data_size, const void *data)
Handle a datum we've received from another peer.
int GDS_am_closest_peer(const struct GNUNET_HashCode *key, const struct GNUNET_CONTAINER_BloomFilter *bloom)
Check whether my identity is closer than any known peers.
Last possible valid result.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
Handle for ATS address suggestion requests.
struct PeerInfo * tail
Tail of DLL.
static void handle_dht_p2p_result(void *cls, const struct PeerResultMessage *prm)
Core handler for p2p result messages.
uint32_t hop_count
Hop count.
void GDS_CLIENTS_process_get_resp(enum GNUNET_BLOCK_Type type, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
Check if some client is monitoring GET RESP messages and notify them in that case.
int GNUNET_BLOCK_group_serialize(struct GNUNET_BLOCK_Group *bg, uint32_t *nonce, void **raw_data, size_t *raw_data_size)
Serialize state of a block group.
GNUnet DHT tracking of requests for routing replies.
Internal representation of the hash map.
Type of a block that contains a HELLO for a peer (for DHT and CADET find-peer operations).
Message handler for a specific message type.
GNUNET_DHT_RouteOption
Options for routing.
uint32_t desired_replication_level
Replication level for this message.
void GNUNET_TRANSPORT_offer_hello_cancel(struct GNUNET_TRANSPORT_OfferHelloHandle *ohh)
Cancel the request to transport to offer the HELLO message.
#define GNUNET_MESSAGE_TYPE_DHT_P2P_GET
Peer tries to find data in DHT.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the content expire?
void GDS_ROUTING_process(enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute expiration_time, const struct GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, const void *data, size_t data_size)
Handle a reply (route to origin).
struct GNUNET_ATS_ConnectivitySuggestHandle * sh
Handle to active connectivity suggestion operation, or NULL.
The block is obtained from the local database, skip cryptographic checks.
Peers are grouped into buckets.
static void handle_local_result(void *cls, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute expiration_time, const struct GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, const void *data, size_t data_size)
Handle a result from local datacache for a GET operation.
#define MAXIMUM_REPLICATION_LEVEL
Maximum allowed replication level for all requests.
uint32_t bf_mutator
Bloomfilter mutator.
Valid result, and there may be more.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_P2P_PUT.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Entry for a peer in a bucket.
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
GNUNET_BLOCK_EvaluationResult
Possible ways for how a block may relate to a query.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_MQ_Envelope * env
static void process_reply_with_path(struct GNUNET_TIME_Absolute expiration_time, const struct GNUNET_HashCode *key, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, enum GNUNET_BLOCK_Type type, size_t data_size, const void *data)
Process a reply, after the get_path has been updated.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
int 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.
static int check_dht_p2p_put(void *cls, const struct PeerPutMessage *put)
Check validity of a p2p put request.
static struct GNUNET_CONTAINER_MultiPeerMap * all_connected_peers
Hash map of all CORE-connected peers, for easy removal from k_buckets on disconnect.
static unsigned long long payload
How much data are we currently storing in the database?
struct GNUNET_BLOCK_Group * GNUNET_BLOCK_group_create(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, uint32_t nonce, const void *raw_data, size_t raw_data_size,...)
Create a new block group.
static struct GNUNET_CORE_Handle * core_api
Handle to CORE.
static int check_dht_p2p_get(void *cls, const struct PeerGetMessage *get)
Check validity of p2p get request.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
uint32_t xquery_size
Size of the extended query.
int GDS_NEIGHBOURS_handle_get(enum GNUNET_BLOCK_Type type, enum GNUNET_DHT_RouteOption options, uint32_t desired_replication_level, uint32_t hop_count, const struct GNUNET_HashCode *key, const void *xquery, size_t xquery_size, struct GNUNET_BLOCK_Group *bg, struct GNUNET_CONTAINER_BloomFilter *peer_bf)
Perform a GET operation.
uint32_t strength
How much would we like to connect to this peer?
Specified block type not supported by this plugin.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the content expire?
Handle to a message queue.
static void handle_dht_p2p_put(void *cls, const struct PeerPutMessage *put)
Core handler for p2p put requests.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
uint32_t options
Processing options.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
GNUnet DHT service's datacache integration.
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
The identity of the host (wraps the signing key of the peer).
#define GNUNET_PACKED
gcc-ism to get packed structs.
static struct PendingResolutions * head
Head of list of pending resolution requests.
uint32_t type
Content type.
struct GNUNET_TIME_Relative hello_expiration
Hello address expiration.
const struct GNUNET_PeerIdentity * id
What is the identity of the peer?
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
Query format does not match block type (invalid query).
Automatic transport selection and outbound bandwidth determination.
struct GNUNET_MQ_Handle * mq
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
static void try_connect(const struct GNUNET_PeerIdentity *pid, const struct GNUNET_MessageHeader *h)
Consider if we want to connect to a given peer, and if so let ATS know.
const struct GNUNET_HELLO_Message * GDS_HELLO_get(const struct GNUNET_PeerIdentity *peer)
Obtain a peer's HELLO if available.
static void send_find_peer_message(void *cls)
Task to send a find peer message for our own peer identifier so that we can find the closest peers in...
struct GNUNET_TRANSPORT_OfferHelloHandle * GNUNET_TRANSPORT_offer_hello(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_MessageHeader *hello, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Offer the transport service the HELLO of another peer.
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
static struct GNUNET_ATS_ConnectivityHandle * ats_ch
Handle to ATS connectivity.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
#define LOG_TRAFFIC(kind,...)
static void handle_core_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Method called whenever a peer disconnects.
static unsigned int bucket_size
Maximum size for each bucket.
enum GNUNET_BLOCK_EvaluationResult GDS_DATACACHE_handle_get(const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, const void *xquery, size_t xquery_size, struct GNUNET_BLOCK_Group *bg, GDS_DATACACHE_GetCallback gc, void *gc_cls)
Handle a GET request we've received from another peer.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
static struct GNUNET_CONTAINER_MultiPeerMap * all_desired_peers
Hash map of all peers we would like to be connected to.
Time for absolute times used by GNUnet, in microseconds.
void GDS_ROUTING_add(const struct GNUNET_PeerIdentity *sender, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *bg, enum GNUNET_DHT_RouteOption options, const struct GNUNET_HashCode *key, const void *xquery, size_t xquery_size)
Add a new entry to our routing table.
static int log_route_details_stderr
Should routing details be logged to stderr (for debugging)?
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
double GDS_NSE_get()
Return the log of the current network size estimate.
int GDS_NEIGHBOURS_init()
Initialize neighbours subsystem.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
struct GNUNET_MQ_Handle * mq
Handle for sending messages to this peer.
Block to store a cadet regex state.
static unsigned int get_target_peers(const struct GNUNET_HashCode *key, struct GNUNET_CONTAINER_BloomFilter *bloom, uint32_t hop_count, uint32_t target_replication, struct PeerInfo ***targets)
Compute the set of peers that the given request should be forwarded to.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
const struct GNUNET_CONFIGURATION_Handle * GDS_cfg
Configuration we use.
uint32_t data
The data value.
Handle to the ATS subsystem for connectivity management.
#define GNUNET_MESSAGE_TYPE_DHT_P2P_PUT
Peer is storing data in DHT.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
int GNUNET_CONTAINER_multipeermap_contains(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Check if the map contains any value under the given key (including values that are NULL)...
struct GNUNET_HashCode key
The key of the corresponding GET request.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Query is valid, no reply given.
void GDS_NEIGHBOURS_handle_reply(const struct GNUNET_PeerIdentity *target, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute expiration_time, const struct GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, const void *data, size_t data_size)
Handle a reply (route to origin).
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_CONTAINER_bloomfilter_free(struct GNUNET_CONTAINER_BloomFilter *bf)
Free the space associated with a filter in memory, flush to drive if needed (do not free the space on...
static void offer_hello_done(void *cls)
Function called when GNUNET_TRANSPORT_offer_hello() is done.
static void * handle_core_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a peer connects.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Each peer along the way should look at 'enc' (otherwise only the k-peers closest to the key should lo...
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
GNUnet DHT integration with NSE.
void GDS_CLIENTS_handle_reply(struct GNUNET_TIME_Absolute expiration, const struct GNUNET_HashCode *key, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, enum GNUNET_BLOCK_Type type, size_t data_size, const void *data)
Handle a reply we've received from another peer.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT
Data is returned to peer from DHT.
Time for relative time used by GNUnet, in microseconds.
void GNUNET_BLOCK_group_destroy(struct GNUNET_BLOCK_Group *bg)
Destroy resources used by a block group.
int GNUNET_BLOCK_group_set_seen(struct GNUNET_BLOCK_Group *bg, const struct GNUNET_HashCode *seen_results, unsigned int seen_results_count)
Update block group to filter out the given results.
#define gettext_noop(String)
uint32_t bits[512/8/sizeof(uint32_t)]
#define DEFAULT_BUCKET_SIZE
What is the maximum number of peers in a given bucket.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
int GDS_NEIGHBOURS_handle_put(enum GNUNET_BLOCK_Type type, enum GNUNET_DHT_RouteOption options, uint32_t desired_replication_level, struct GNUNET_TIME_Absolute expiration_time, uint32_t hop_count, struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *key, unsigned int put_path_length, struct GNUNET_PeerIdentity *put_path, const void *data, size_t data_size)
Perform a PUT operation.