GNUnet  0.17.6
Data Structures | Macros | Typedefs | Functions
gnunet-service-fs_cp.h File Reference

API to handle 'connected peers'. More...

#include "fs.h"
#include "gnunet-service-fs.h"
Include dependency graph for gnunet-service-fs_cp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GSF_PeerPerformanceData
 Performance data kept for a peer. More...
 

Macros

#define MAX_QUEUE_PER_PEER   24
 Maximum number of outgoing messages we queue per peer. More...
 
#define P2P_SUCCESS_LIST_SIZE   8
 Length of the P2P success tracker. More...
 
#define CS2P_SUCCESS_LIST_SIZE   8
 Length of the CS-2-P success tracker. More...
 

Typedefs

typedef void(* GSF_ConnectedPeerIterator) (void *cls, const struct GNUNET_PeerIdentity *peer, struct GSF_ConnectedPeer *cp, const struct GSF_PeerPerformanceData *ppd)
 Signature of function called on a connected peer. More...
 
typedef size_t(* GSF_GetMessageCallback) (void *cls, size_t buf_size, void *buf)
 Function called to get a message for transmission. More...
 
typedef void(* GSF_PeerReserveCallback) (void *cls, struct GSF_ConnectedPeer *cp, int success)
 Signature of function called on a reservation success or failure. More...
 

Functions

void * GSF_peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
 A peer connected to us. More...
 
struct GSF_ConnectedPeerGSF_peer_get_ (const struct GNUNET_PeerIdentity *peer)
 Get a handle for a connected peer. More...
 
void GSF_update_peer_latency_ (const struct GNUNET_PeerIdentity *id, struct GNUNET_TIME_Relative latency)
 Update the latency information kept for the given peer. More...
 
void GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query, uint32_t priority, struct GNUNET_MQ_Envelope *env)
 Transmit a message to the given peer as soon as possible. More...
 
void GSF_peer_update_performance_ (struct GSF_ConnectedPeer *cp, struct GNUNET_TIME_Absolute request_time, uint32_t request_priority)
 Report on receiving a reply; update the performance record of the given peer. More...
 
void GSF_peer_update_responder_client_ (struct GSF_ConnectedPeer *cp, struct GSF_LocalClient *initiator_client)
 Report on receiving a reply in response to an initiating client. More...
 
void GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp, const struct GSF_ConnectedPeer *initiator_peer)
 Report on receiving a reply in response to an initiating peer. More...
 
void handle_p2p_migration_stop (void *cls, const struct MigrationStopMessage *message)
 Handle P2P GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP message. More...
 
void handle_p2p_get (void *cls, const struct GetMessage *gm)
 Handle P2P "QUERY" message. More...
 
struct GSF_PeerPerformanceDataGSF_get_peer_performance_data_ (struct GSF_ConnectedPeer *cp)
 Return the performance data record for the given peer. More...
 
void GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp, struct GNUNET_TIME_Absolute block_time)
 Ask a peer to stop migrating data to us until the given point in time. More...
 
void GSF_peer_disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
 A peer disconnected from us. More...
 
void GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc)
 Notification that a local client disconnected. More...
 
void GSF_connected_peer_change_preference_ (struct GSF_ConnectedPeer *cp, uint64_t pref)
 Notify core about a preference we have for the given peer (to allocate more resources towards it). More...
 
void GSF_connected_peer_get_identity_ (const struct GSF_ConnectedPeer *cp, struct GNUNET_PeerIdentity *id)
 Obtain the identity of a connected peer. More...
 
const struct GNUNET_PeerIdentityGSF_connected_peer_get_identity2_ (const struct GSF_ConnectedPeer *cp)
 Obtain the identity of a connected peer. More...
 
void GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls)
 Iterate over all connected peers. More...
 
void GSF_connected_peer_init_ (void)
 Initialize peer management subsystem. More...
 
void GSF_connected_peer_done_ (void)
 Shutdown peer management subsystem. More...
 

Detailed Description

API to handle 'connected peers'.

Author
Christian Grothoff

Definition in file gnunet-service-fs_cp.h.

Macro Definition Documentation

◆ MAX_QUEUE_PER_PEER

#define MAX_QUEUE_PER_PEER   24

Maximum number of outgoing messages we queue per peer.

Performance measurements for 2 peer setup for 50 MB file (using perf_gnunet_service_fs_p2p):

24: 2-3 MB/s # ~ 24 MB RAM 256: 8 MB/s # ~256 MB RAM

Conclusion: 24 should suffice (reasonable performance, no excessive memory use).

Definition at line 45 of file gnunet-service-fs_cp.h.

◆ P2P_SUCCESS_LIST_SIZE

#define P2P_SUCCESS_LIST_SIZE   8

Length of the P2P success tracker.

Note that having a very long list can also hurt performance.

Definition at line 51 of file gnunet-service-fs_cp.h.

◆ CS2P_SUCCESS_LIST_SIZE

#define CS2P_SUCCESS_LIST_SIZE   8

Length of the CS-2-P success tracker.

Note that having a very long list can also hurt performance.

Definition at line 57 of file gnunet-service-fs_cp.h.

Typedef Documentation

◆ GSF_ConnectedPeerIterator

typedef void(* GSF_ConnectedPeerIterator) (void *cls, const struct GNUNET_PeerIdentity *peer, struct GSF_ConnectedPeer *cp, const struct GSF_PeerPerformanceData *ppd)

Signature of function called on a connected peer.

Parameters
clsclosure
peeridentity of the peer
cphandle to the connected peer record
perfpeer performance data

Definition at line 156 of file gnunet-service-fs_cp.h.

◆ GSF_GetMessageCallback

typedef size_t(* GSF_GetMessageCallback) (void *cls, size_t buf_size, void *buf)

Function called to get a message for transmission.

Parameters
clsclosure
buf_sizenumber of bytes available in buf
bufwhere to copy the message, NULL on error (peer disconnect)
Returns
number of bytes copied to buf, can be 0 (without indicating an error)

Definition at line 171 of file gnunet-service-fs_cp.h.

◆ GSF_PeerReserveCallback

typedef void(* GSF_PeerReserveCallback) (void *cls, struct GSF_ConnectedPeer *cp, int success)

Signature of function called on a reservation success or failure.

Parameters
clsclosure
cphandle to the connected peer record
successGNUNET_YES on success, GNUNET_NO on failure

Definition at line 184 of file gnunet-service-fs_cp.h.

Function Documentation

◆ GSF_peer_connect_handler()

void* GSF_peer_connect_handler ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_MQ_Handle mq 
)

A peer connected to us.

Setup the connected peer records.

Parameters
clsNULL
peeridentity of peer that connected
mqmessage queue for talking to peer
Returns
internal handle for the peer

Definition at line 569 of file gnunet-service-fs_cp.c.

572 {
573  struct GSF_ConnectedPeer *cp;
574 
575  if (0 ==
577  peer))
578  return NULL;
580  "Connected to peer %s\n",
581  GNUNET_i2s (peer));
582  cp = GNUNET_new (struct GSF_ConnectedPeer);
583  cp->ppd.pid = GNUNET_PEER_intern (peer);
584  cp->ppd.peer = peer;
585  cp->mq = mq;
587  cp->rc =
589  peer,
590  DBLOCK_SIZE,
591  &ats_reserve_callback, cp);
593  GNUNET_YES);
597  cp),
598  cp,
601  gettext_noop ("# peers connected"),
603  GNUNET_NO);
606  "fs",
607  peer,
608  "respect",
610  cp);
612  cp);
613  return cp;
614 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
Definition: fs.h:40
#define gettext_noop(String)
Definition: gettext.h:69
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
struct GNUNET_PeerIdentity GSF_my_id
Identity of this peer.
struct GNUNET_ATS_PerformanceHandle * GSF_ats
Handle to ATS service.
const struct GNUNET_PeerIdentity * GSF_connected_peer_get_identity2_(const struct GSF_ConnectedPeer *cp)
Obtain the identity of a connected peer.
static void ats_reserve_callback(void *cls, const struct GNUNET_PeerIdentity *peer, int32_t amount, struct GNUNET_TIME_Relative res_delay)
Function called by core upon success or failure of our bandwidth reservation request.
static struct GNUNET_PEERSTORE_Handle * peerstore
Handle to peerstore service.
static void peer_respect_cb(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
Function called by PEERSTORE with peer respect record.
static int consider_peer_for_forwarding(void *cls, const struct GNUNET_HashCode *key, struct GSF_PendingRequest *pr)
Function called for each pending request whenever a new peer connects, giving us a chance to decide a...
static struct GNUNET_CONTAINER_MultiPeerMap * cp_map
Map from peer identities to struct GSF_ConnectPeer entries.
void GSF_iterate_pending_requests_(GSF_PendingRequestIterator it, void *cls)
Iterate over all pending requests.
struct GNUNET_ATS_ReservationContext * GNUNET_ATS_reserve_bandwidth(struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer, int32_t amount, GNUNET_ATS_ReservationCallback rcb, void *rcb_cls)
Reserve inbound bandwidth from the given peer.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_log(kind,...)
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_YES
@ GNUNET_NO
Definition: gnunet_common.h:98
struct GNUNET_LOAD_Value * GNUNET_LOAD_value_init(struct GNUNET_TIME_Relative autodecline)
Create a new load value.
Definition: load.c:124
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUNET_PEER_Id GNUNET_PEER_intern(const struct GNUNET_PeerIdentity *pid)
Intern an peer identity.
Definition: peer.c:107
struct GNUNET_PEERSTORE_IterateContext * GNUNET_PEERSTORE_iterate(struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Iterate over records matching supplied key information.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
A connected peer.
struct GNUNET_ATS_ReservationContext * rc
Context of our GNUNET_ATS_reserve_bandwidth call (or NULL).
struct GNUNET_PEERSTORE_IterateContext * respect_iterate_req
Handle to the PEERSTORE iterate request for peer respect value.
struct GSF_PeerPerformanceData ppd
Performance data for this peer.
struct GNUNET_CONTAINER_MultiHashMap * request_map
Active requests from this neighbour, map of query to struct PeerRequest.
struct GNUNET_MQ_Handle * mq
Handle for an active request for transmission to this peer.
struct GNUNET_LOAD_Value * transmission_delay
How long does it typically take for us to transmit a message to this peer? (delay between the request...
const struct GNUNET_PeerIdentity * peer
The peer's identity (pointer).
GNUNET_PEER_Id pid
The peer's identity (interned version).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References ats_reserve_callback(), consider_peer_for_forwarding(), cp_map, DBLOCK_SIZE, gettext_noop, GNUNET_ATS_reserve_bandwidth(), GNUNET_break, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_LOAD_value_init(), GNUNET_log, GNUNET_memcmp, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PEER_intern(), GNUNET_PEERSTORE_iterate(), GNUNET_STATISTICS_set(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, GSF_ats, GSF_connected_peer_get_identity2_(), GSF_iterate_pending_requests_(), GSF_my_id, GSF_stats, mq, GSF_ConnectedPeer::mq, GSF_PeerPerformanceData::peer, peer, peer_respect_cb(), peerstore, GSF_PeerPerformanceData::pid, GSF_ConnectedPeer::ppd, GSF_ConnectedPeer::rc, GSF_ConnectedPeer::request_map, GSF_ConnectedPeer::respect_iterate_req, and GSF_PeerPerformanceData::transmission_delay.

Referenced by main_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_peer_get_()

struct GSF_ConnectedPeer* GSF_peer_get_ ( const struct GNUNET_PeerIdentity peer)

Get a handle for a connected peer.

Parameters
peerpeer's identity
Returns
NULL if this peer is not currently connected

Definition at line 643 of file gnunet-service-fs_cp.c.

644 {
645  if (NULL == cp_map)
646  return NULL;
648 }
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.

References cp_map, GNUNET_CONTAINER_multipeermap_get(), and peer.

Referenced by GSF_update_peer_latency_(), handle_p2p_get(), and put_migration_continuation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_update_peer_latency_()

void GSF_update_peer_latency_ ( const struct GNUNET_PeerIdentity id,
struct GNUNET_TIME_Relative  latency 
)

Update the latency information kept for the given peer.

Parameters
idpeer record to update
latencycurrent latency value

Definition at line 302 of file gnunet-service-fs_cp.c.

304 {
305  struct GSF_ConnectedPeer *cp;
306 
307  cp = GSF_peer_get_ (id);
308  if (NULL == cp)
309  return; /* we're not yet connected at the core level, ignore */
311  latency);
312 }
struct GSF_ConnectedPeer * GSF_peer_get_(const struct GNUNET_PeerIdentity *peer)
Get a handle for a connected peer.
void GNUNET_LOAD_value_set_decline(struct GNUNET_LOAD_Value *load, struct GNUNET_TIME_Relative autodecline)
Change the value by which the load automatically declines.
Definition: load.c:142

References GNUNET_LOAD_value_set_decline(), GSF_peer_get_(), GSF_ConnectedPeer::ppd, and GSF_PeerPerformanceData::transmission_delay.

Referenced by update_latencies().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_peer_transmit_()

void GSF_peer_transmit_ ( struct GSF_ConnectedPeer cp,
int  is_query,
uint32_t  priority,
struct GNUNET_MQ_Envelope env 
)

Transmit a message to the given peer as soon as possible.

If the peer disconnects before the transmission can happen, the callback is invoked with a 'NULL' buffer.

Parameters
cptarget peer
is_queryis this a query (GNUNET_YES) or content (GNUNET_NO)
priorityhow important is this request?
envenvelope of message to send

If the peer disconnects before the transmission can happen, the callback is invoked with a NULL buffer.

Parameters
cptarget peer
is_queryis this a query (GNUNET_YES) or content (GNUNET_NO) or neither (GNUNET_SYSERR)
priorityhow important is this request?
timeoutwhen does this request timeout
sizenumber of bytes we would like to send to the peer
envmessage to send

Definition at line 1350 of file gnunet-service-fs_cp.c.

1354 {
1355  struct GSF_PeerTransmitHandle *pth;
1356  struct GSF_PeerTransmitHandle *pos;
1357  struct GSF_PeerTransmitHandle *prev;
1358 
1359  pth = GNUNET_new (struct GSF_PeerTransmitHandle);
1361  pth->env = env;
1362  pth->is_query = is_query;
1363  pth->priority = priority;
1364  pth->cp = cp;
1365  /* insertion sort (by priority, descending) */
1366  prev = NULL;
1367  pos = cp->pth_head;
1368  while ((NULL != pos) && (pos->priority > priority))
1369  {
1370  prev = pos;
1371  pos = pos->next;
1372  }
1374  cp->pth_tail,
1375  prev,
1376  pth);
1377  if (GNUNET_YES == is_query)
1378  cp->ppd.pending_queries++;
1379  else if (GNUNET_NO == is_query)
1380  cp->ppd.pending_replies++;
1381  schedule_transmission (pth);
1382 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void schedule_transmission(struct GSF_PeerTransmitHandle *pth)
If ready (bandwidth reserved), try to schedule transmission via core for the given handle.
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:110
struct GSF_PeerTransmitHandle * pth_head
Messages (replies, queries, content migration) we would like to send to this peer in the near future.
struct GSF_PeerTransmitHandle * pth_tail
Messages (replies, queries, content migration) we would like to send to this peer in the near future.
unsigned int pending_replies
Number of pending replies (queries are not counted)
unsigned int pending_queries
Number of pending queries (replies are not counted)
Handle to cancel a transmission request.
int is_query
GNUNET_YES if this is a query, GNUNET_NO for content.
struct GSF_PeerTransmitHandle * next
Kept in a doubly-linked list.
uint32_t priority
Priority of this request.
struct GNUNET_TIME_Absolute transmission_request_start_time
Time when this transmission request was issued.
struct GSF_PeerTransmitHandle * prev
Kept in a doubly-linked list.
struct GSF_ConnectedPeer * cp
Peer this request targets.
struct GNUNET_MQ_Envelope * env
Envelope with the actual message.

References GSF_PeerTransmitHandle::cp, env, GSF_PeerTransmitHandle::env, GNUNET_CONTAINER_DLL_insert_after, GNUNET_new, GNUNET_NO, GNUNET_TIME_absolute_get(), GNUNET_YES, GSF_PeerTransmitHandle::is_query, GSF_PeerTransmitHandle::next, GSF_PeerPerformanceData::pending_queries, GSF_PeerPerformanceData::pending_replies, GSF_ConnectedPeer::ppd, GSF_PeerTransmitHandle::prev, GSF_PeerTransmitHandle::priority, GSF_ConnectedPeer::pth_head, GSF_ConnectedPeer::pth_tail, schedule_transmission(), and GSF_PeerTransmitHandle::transmission_request_start_time.

Referenced by get_randomized_delay(), GSF_block_peer_migration_(), handle_p2p_reply(), schedule_peer_transmission(), and transmit_content().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_peer_update_performance_()

void GSF_peer_update_performance_ ( struct GSF_ConnectedPeer cp,
struct GNUNET_TIME_Absolute  request_time,
uint32_t  request_priority 
)

Report on receiving a reply; update the performance record of the given peer.

Parameters
cpresponding peer (will be updated)
request_timetime at which the original query was transmitted
request_prioritypriority of the original request

Definition at line 1393 of file gnunet-service-fs_cp.c.

1396 {
1397  struct GNUNET_TIME_Relative delay;
1398 
1399  delay = GNUNET_TIME_absolute_get_duration (request_time);
1403  cp->ppd.avg_priority =
1404  (cp->ppd.avg_priority * (RUNAVG_DELAY_N - 1)
1405  + request_priority) / RUNAVG_DELAY_N;
1406 }
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
#define RUNAVG_DELAY_N
Ratio for moving average delay calculation.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:435
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
double avg_priority
Average priority of successful replies.
struct GNUNET_TIME_Relative avg_reply_delay
Average delay between sending the peer a request and getting a reply (only calculated over the reques...

References GSF_PeerPerformanceData::avg_priority, GSF_PeerPerformanceData::avg_reply_delay, delay, GNUNET_TIME_absolute_get_duration(), GSF_ConnectedPeer::ppd, GNUNET_TIME_Relative::rel_value_us, and RUNAVG_DELAY_N.

Referenced by process_reply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_peer_update_responder_client_()

void GSF_peer_update_responder_client_ ( struct GSF_ConnectedPeer cp,
struct GSF_LocalClient initiator_client 
)

Report on receiving a reply in response to an initiating client.

Remember that this peer is good for this client.

Parameters
cpresponding peer (will be updated)
initiator_clientlocal client on responsible for query

Definition at line 1417 of file gnunet-service-fs_cp.c.

1419 {
1421  % CS2P_SUCCESS_LIST_SIZE] = initiator_client;
1422 }
#define CS2P_SUCCESS_LIST_SIZE
Length of the CS-2-P success tracker.
unsigned int last_client_replies_woff
Which offset in last_client_replies will be updated next? (we go round-robin).
struct GSF_LocalClient * last_client_replies[8]
List of the last clients for which this peer successfully answered a query.

References CS2P_SUCCESS_LIST_SIZE, GSF_PeerPerformanceData::last_client_replies, GSF_ConnectedPeer::last_client_replies_woff, and GSF_ConnectedPeer::ppd.

◆ GSF_peer_update_responder_peer_()

void GSF_peer_update_responder_peer_ ( struct GSF_ConnectedPeer cp,
const struct GSF_ConnectedPeer initiator_peer 
)

Report on receiving a reply in response to an initiating peer.

Remember that this peer is good for this initiating peer.

Parameters
cpresponding peer (will be updated)
initiator_peerother peer responsible for query

Definition at line 1433 of file gnunet-service-fs_cp.c.

1435 {
1436  unsigned int woff;
1437 
1439  GNUNET_PEER_change_rc (cp->ppd.last_p2p_replies[woff], -1);
1440  cp->ppd.last_p2p_replies[woff] = initiator_peer->ppd.pid;
1441  GNUNET_PEER_change_rc (initiator_peer->ppd.pid, 1);
1442  cp->last_p2p_replies_woff = (woff + 1) % P2P_SUCCESS_LIST_SIZE;
1443 }
#define P2P_SUCCESS_LIST_SIZE
Length of the P2P success tracker.
void GNUNET_PEER_change_rc(GNUNET_PEER_Id id, int delta)
Change the reference counter of an interned PID.
Definition: peer.c:197
unsigned int last_p2p_replies_woff
Which offset in last_p2p_replies will be updated next? (we go round-robin).
GNUNET_PEER_Id last_p2p_replies[8]
List of the last PIDs for which this peer successfully answered a query; We use 0 to indicate no succ...

References GNUNET_PEER_change_rc(), GSF_PeerPerformanceData::last_p2p_replies, GSF_ConnectedPeer::last_p2p_replies_woff, P2P_SUCCESS_LIST_SIZE, GSF_PeerPerformanceData::pid, and GSF_ConnectedPeer::ppd.

Here is the call graph for this function:

◆ handle_p2p_migration_stop()

void handle_p2p_migration_stop ( void *  cls,
const struct MigrationStopMessage msm 
)

Handle P2P GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP message.

Parameters
clsclosure, the struct GSF_ConnectedPeer
msmthe actual message

Definition at line 658 of file gnunet-service-fs_cp.c.

660 {
661  struct GSF_ConnectedPeer *cp = cls;
662  struct GNUNET_TIME_Relative bt;
663 
665  gettext_noop ("# migration stop messages received"),
666  1, GNUNET_NO);
669  _ ("Migration of content to peer `%s' blocked for %s\n"),
670  GNUNET_i2s (cp->ppd.peer),
673  if ((NULL == cp->mig_revive_task) &&
674  (NULL == cp->respect_iterate_req))
675  {
676  GSF_push_stop_ (cp);
677  cp->mig_revive_task =
679  &revive_migration, cp);
680  }
681 }
static void revive_migration(void *cls)
It may be time to re-start migrating content to this peer.
void GSF_push_stop_(struct GSF_ConnectedPeer *peer)
A peer disconnected from us.
@ GNUNET_ERROR_TYPE_INFO
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.
Definition: scheduler.c:1254
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:627
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:315
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:570
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
struct GNUNET_SCHEDULER_Task * mig_revive_task
Task scheduled to revive migration to this peer.
struct GNUNET_TIME_Absolute migration_blocked_until
Point in time until which this peer does not want us to migrate content to it.
struct GNUNET_TIME_RelativeNBO duration
How long should the block last?

References _, MigrationStopMessage::duration, gettext_noop, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative_ntoh(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, GSF_push_stop_(), GSF_stats, GSF_ConnectedPeer::mig_revive_task, GSF_PeerPerformanceData::migration_blocked_until, GSF_PeerPerformanceData::peer, GSF_ConnectedPeer::ppd, GSF_ConnectedPeer::respect_iterate_req, and revive_migration().

Here is the call graph for this function:

◆ handle_p2p_get()

void handle_p2p_get ( void *  cls,
const struct GetMessage gm 
)

Handle P2P "QUERY" message.

Parameters
clsthe struct GSF_ConnectedPeer of the other sender
gmthe actual message

Creates the pending request entry and sets up all of the data structures to that we will process replies properly. Does not initiate forwarding or local database lookups.

Parameters
clsthe other peer involved (sender of the message)
gmthe GET message

Definition at line 1150 of file gnunet-service-fs_cp.c.

1152 {
1153  struct GSF_ConnectedPeer *cps = cls;
1154  struct PeerRequest *peerreq;
1155  struct GSF_PendingRequest *pr;
1156  struct GSF_ConnectedPeer *cp;
1157  const struct GNUNET_PeerIdentity *target;
1159  uint16_t msize;
1160  unsigned int bits;
1161  const struct GNUNET_PeerIdentity *opt;
1162  uint32_t bm;
1163  size_t bfsize;
1164  uint32_t ttl_decrement;
1165  struct TestExistClosure tec;
1166  GNUNET_PEER_Id spid;
1167  const struct GSF_PendingRequestData *prd;
1168 
1169  msize = ntohs (gm->header.size);
1170  tec.type = ntohl (gm->type);
1171  bm = ntohl (gm->hash_bitmap);
1172  bits = 0;
1173  while (bm > 0)
1174  {
1175  if (1 == (bm & 1))
1176  bits++;
1177  bm >>= 1;
1178  }
1179  opt = (const struct GNUNET_PeerIdentity *) &gm[1];
1180  bfsize = msize - sizeof(struct GetMessage) - bits * sizeof(struct
1183  gettext_noop
1184  ("# GET requests received (from other peers)"),
1185  1,
1186  GNUNET_NO);
1188  bm = ntohl (gm->hash_bitmap);
1189  bits = 0;
1190  if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO))
1191  cp = GSF_peer_get_ (&opt[bits++]);
1192  else
1193  cp = cps;
1194  if (NULL == cp)
1195  {
1196  if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO))
1198  "Failed to find RETURN-TO peer `%s' in connection set. Dropping query.\n",
1199  GNUNET_i2s (&opt[bits - 1]));
1200 
1201  else
1203  "Failed to find peer `%s' in connection set. Dropping query.\n",
1204  GNUNET_i2s (cps->ppd.peer));
1206  gettext_noop
1207  (
1208  "# requests dropped due to missing reverse route"),
1209  1,
1210  GNUNET_NO);
1211  return;
1212  }
1213  unsigned int queue_size = GNUNET_MQ_get_length (cp->mq);
1214  queue_size += cp->ppd.pending_replies + cp->delay_queue_size;
1215  if (queue_size > MAX_QUEUE_PER_PEER)
1216  {
1218  "Peer `%s' has too many replies queued already. Dropping query.\n",
1219  GNUNET_i2s (cps->ppd.peer));
1221  gettext_noop (
1222  "# requests dropped due to full reply queue"),
1223  1,
1224  GNUNET_NO);
1225  return;
1226  }
1227  /* note that we can really only check load here since otherwise
1228  * peers could find out that we are overloaded by not being
1229  * disconnected after sending us a malformed query... */
1230  tec.priority = bound_priority (ntohl (gm->priority),
1231  cps);
1232  if (tec.priority < 0)
1233  {
1235  "Dropping query from `%s', this peer is too busy.\n",
1236  GNUNET_i2s (cps->ppd.peer));
1237  return;
1238  }
1240  "Received request for `%s' of type %u from peer `%s' with flags %u\n",
1241  GNUNET_h2s (&gm->query),
1242  (unsigned int) tec.type,
1243  GNUNET_i2s (cps->ppd.peer),
1244  (unsigned int) bm);
1245  target =
1246  (0 !=
1247  (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) ? (&opt[bits++]) : NULL;
1249  spid = 0;
1250  if ((GNUNET_LOAD_get_load (cp->ppd.transmission_delay) > 3 * (1
1251  + tec.priority))
1253  GNUNET_CONSTANTS_MAX_CORK_DELAY.rel_value_us * 2
1255  {
1256  /* don't have BW to send to peer, or would likely take longer than we have for it,
1257  * so at best indirect the query */
1258  tec.priority = 0;
1260  spid = GNUNET_PEER_intern (cps->ppd.peer);
1261  GNUNET_assert (0 != spid);
1262  }
1263  tec.ttl = bound_ttl (ntohl (gm->ttl),
1264  tec.priority);
1265  /* decrement ttl (always) */
1266  ttl_decrement =
1268  TTL_DECREMENT);
1269  if ((tec.ttl < 0) &&
1270  (((int32_t) (tec.ttl - ttl_decrement)) > 0))
1271  {
1273  "Dropping query from `%s' due to TTL underflow (%d - %u).\n",
1274  GNUNET_i2s (cps->ppd.peer),
1275  tec.ttl,
1276  ttl_decrement);
1278  gettext_noop
1279  ("# requests dropped due TTL underflow"), 1,
1280  GNUNET_NO);
1281  /* integer underflow => drop (should be very rare)! */
1282  return;
1283  }
1284  tec.ttl -= ttl_decrement;
1285 
1286  /* test if the request already exists */
1287  tec.finished = GNUNET_NO;
1289  &gm->query,
1290  &test_exist_cb,
1291  &tec);
1292  if (GNUNET_YES == tec.finished)
1293  return; /* merged into existing request, we're done */
1294 
1295  peerreq = GNUNET_new (struct PeerRequest);
1296  peerreq->cp = cp;
1298  tec.type,
1299  &gm->query,
1300  target,
1301  (bfsize > 0)
1302  ? (const char *) &opt[bits]
1303  : NULL,
1304  bfsize,
1305  1 /* anonymity */,
1306  (uint32_t) tec.priority,
1307  tec.ttl,
1308  spid,
1309  GNUNET_PEER_intern (cps->ppd.peer),
1310  NULL, 0, /* replies_seen */
1312  peerreq);
1313  GNUNET_assert (NULL != pr);
1314  prd = GSF_pending_request_get_data_ (pr);
1315  peerreq->pr = pr;
1318  &prd->query,
1319  peerreq,
1322  gettext_noop (
1323  "# P2P query messages received and processed"),
1324  1,
1325  GNUNET_NO);
1327  gettext_noop ("# P2P searches active"),
1328  1,
1329  GNUNET_NO);
1331  GSF_local_lookup_ (pr,
1333  NULL);
1334 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
unsigned int GSF_cover_query_count
How many query messages have we received 'recently' that have not yet been claimed as cover traffic?
void GSF_consider_forwarding(void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_ReplyEvaluationResult result)
Function to be called after we're done processing replies from the local lookup.
struct GNUNET_LOAD_Value * GSF_rt_entry_lifetime
How long do requests typically stay in the routing table?
#define GET_MESSAGE_BIT_TRANSMIT_TO
The peer identity of a peer that had claimed to have the content previously is included (can be used ...
#define TTL_DECREMENT
By which amount do we decrement the TTL for simple forwarding / indirection of the query; in milli-se...
#define GET_MESSAGE_BIT_RETURN_TO
The peer identity of a peer waiting for the reply is included (used if the response should be transmi...
static void handle_p2p_reply(void *cls, enum GNUNET_BLOCK_ReplyEvaluationResult eval, struct GSF_PendingRequest *pr, uint32_t reply_anonymity_level, struct GNUNET_TIME_Absolute expiration, struct GNUNET_TIME_Absolute last_transmission, enum GNUNET_BLOCK_Type type, const void *data, size_t data_len)
Handle a reply to a pending request.
static int test_exist_cb(void *cls, const struct GNUNET_HashCode *hc, void *value)
Test if the query already exists.
static int32_t bound_priority(uint32_t prio_in, struct GSF_ConnectedPeer *cp)
We've received a request with the specified priority.
static int32_t bound_ttl(int32_t ttl_in, uint32_t prio)
The priority level imposes a bound on the maximum value for the ttl that can be requested.
#define MAX_QUEUE_PER_PEER
Maximum number of outgoing messages we queue per peer.
void GSF_local_lookup_(struct GSF_PendingRequest *pr, GSF_LocalLookupContinuation cont, void *cont_cls)
Look up the request in the local datastore.
struct GSF_PendingRequestData * GSF_pending_request_get_data_(struct GSF_PendingRequest *pr)
Obtain the public data associated with a pending request.
struct GSF_PendingRequest * GSF_pending_request_create_(enum GSF_PendingRequestOptions options, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *query, const struct GNUNET_PeerIdentity *target, const char *bf_data, size_t bf_size, uint32_t anonymity_level, uint32_t priority, int32_t ttl, GNUNET_PEER_Id sender_pid, GNUNET_PEER_Id origin_pid, const struct GNUNET_HashCode *replies_seen, unsigned int replies_seen_count, GSF_PendingRequestReplyHandler rh, void *rh_cls)
Create a new pending request.
GSF_PendingRequestOptions
Options for pending requests (bits to be ORed).
@ GSF_PRO_DEFAULTS
No special options (P2P-default).
@ GSF_PRO_FORWARD_ONLY
Request must only be forwarded (no routing)
#define GNUNET_CONSTANTS_MAX_CORK_DELAY
How long do we delay messages to get larger packet sizes (CORKing)?
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
double GNUNET_LOAD_get_average(struct GNUNET_LOAD_Value *load)
Get the average value given to update so far.
Definition: load.c:215
double GNUNET_LOAD_get_load(struct GNUNET_LOAD_Value *load)
Get the current load.
Definition: load.c:200
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:291
unsigned int GNUNET_PEER_Id
A GNUNET_PEER_Id is simply a shorter version of a "struct GNUNET_PeerIdentifier" that can be used ins...
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
The identity of the host (wraps the signing key of the peer).
unsigned int delay_queue_size
Number of entries in delayed_head DLL.
Public data (in the sense of not encapsulated within 'gnunet-service-fs_pr', not in the sense of netw...
int has_started
Has this request been started yet (local/p2p operations)? Or are we still constructing it?
struct GNUNET_HashCode query
Primary query hash for this request.
An active request.
Message to the datastore service asking about specific content.
Definition: datastore.h:141
uint32_t type
Desired content type.
Definition: datastore.h:150
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_DATASTORE_GET.
Definition: datastore.h:145
uint32_t priority
How important is this request (network byte order)
struct GNUNET_HashCode query
Hashcodes of the file(s) we're looking for.
int32_t ttl
Relative time to live in MILLISECONDS (network byte order)
uint32_t hash_bitmap
Which of the optional hash codes are present at the end of the message? See GET_MESSAGE_BIT_xx consta...
Information per peer and request.
struct GSF_ConnectedPeer * cp
Which specific peer issued this request?
struct GSF_PendingRequest * pr
Handle to generic request (generic: from peer or local client).
Closure for test_exist_cb().

References bound_priority(), bound_ttl(), PeerRequest::cp, GSF_ConnectedPeer::delay_queue_size, TestExistClosure::finished, GET_MESSAGE_BIT_RETURN_TO, GET_MESSAGE_BIT_TRANSMIT_TO, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONSTANTS_MAX_CORK_DELAY, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_LOAD_get_average(), GNUNET_LOAD_get_load(), GNUNET_log, GNUNET_MQ_get_length(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PEER_intern(), GNUNET_STATISTICS_update(), GNUNET_YES, GSF_consider_forwarding(), GSF_cover_query_count, GSF_local_lookup_(), GSF_peer_get_(), GSF_pending_request_create_(), GSF_pending_request_get_data_(), GSF_PRO_DEFAULTS, GSF_PRO_FORWARD_ONLY, GSF_rt_entry_lifetime, GSF_stats, handle_p2p_reply(), GSF_PendingRequestData::has_started, GetMessage::hash_bitmap, GetMessage::header, MAX_QUEUE_PER_PEER, GSF_ConnectedPeer::mq, options, GSF_PeerPerformanceData::peer, GSF_PeerPerformanceData::pending_replies, GSF_ConnectedPeer::ppd, PeerRequest::pr, GetMessage::priority, TestExistClosure::priority, GetMessage::query, GSF_PendingRequestData::query, GSF_ConnectedPeer::request_map, GNUNET_MessageHeader::size, test_exist_cb(), GSF_PeerPerformanceData::transmission_delay, GetMessage::ttl, TestExistClosure::ttl, TTL_DECREMENT, GetMessage::type, and TestExistClosure::type.

Here is the call graph for this function:

◆ GSF_get_peer_performance_data_()

struct GSF_PeerPerformanceData* GSF_get_peer_performance_data_ ( struct GSF_ConnectedPeer cp)

Return the performance data record for the given peer.

Parameters
cppeer to query
Returns
performance data record for the peer

Definition at line 322 of file gnunet-service-fs_cp.c.

323 {
324  return &cp->ppd;
325 }

References GSF_ConnectedPeer::ppd.

Referenced by handle_p2p_put(), put_migration_continuation(), score_content(), and transmit_content().

Here is the caller graph for this function:

◆ GSF_block_peer_migration_()

void GSF_block_peer_migration_ ( struct GSF_ConnectedPeer cp,
struct GNUNET_TIME_Absolute  block_time 
)

Ask a peer to stop migrating data to us until the given point in time.

Parameters
cppeer to ask
block_timeuntil when to block

Definition at line 1651 of file gnunet-service-fs_cp.c.

1653 {
1654  struct GNUNET_MQ_Envelope *env;
1655  struct MigrationStopMessage *msm;
1656 
1657  if (cp->last_migration_block.abs_value_us > block_time.abs_value_us)
1658  {
1660  "Migration already blocked for another %s\n",
1663  (cp->
1664  last_migration_block), GNUNET_YES));
1665  return; /* already blocked */
1666  }
1667  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to stop migration for %s\n",
1670  GNUNET_YES));
1671  cp->last_migration_block = block_time;
1672  env = GNUNET_MQ_msg (msm,
1674  msm->reserved = htonl (0);
1675  msm->duration
1677  (cp->last_migration_block));
1679  gettext_noop ("# migration stop messages sent"),
1680  1,
1681  GNUNET_NO);
1682  GSF_peer_transmit_ (cp,
1683  GNUNET_SYSERR,
1684  UINT32_MAX,
1685  env);
1686 }
void GSF_peer_transmit_(struct GSF_ConnectedPeer *cp, int is_query, uint32_t priority, struct GNUNET_MQ_Envelope *env)
Transmit a message to the given peer as soon as possible.
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:71
#define GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP
Peer asks us to stop migrating content towards it for a while.
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?
Definition: time.c:404
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:617
uint64_t abs_value_us
The actual value.
struct GNUNET_TIME_Absolute last_migration_block
Time until when we blocked this peer from migrating data to us.
Message send by a peer that wants to be excluded from migration for a while.
uint32_t reserved
Always zero.

References GNUNET_TIME_Absolute::abs_value_us, MigrationStopMessage::duration, env, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP, GNUNET_MQ_msg, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_hton(), GNUNET_YES, GSF_peer_transmit_(), GSF_stats, GSF_ConnectedPeer::last_migration_block, and MigrationStopMessage::reserved.

Referenced by handle_p2p_put(), and put_migration_continuation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_peer_disconnect_handler()

void GSF_peer_disconnect_handler ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  internal_cls 
)

A peer disconnected from us.

Tear down the connected peer record.

Parameters
clsunused
peeridentity of peer that disconnected
internal_clsthe corresponding struct GSF_ConnectedPeer

Definition at line 1477 of file gnunet-service-fs_cp.c.

1480 {
1481  struct GSF_ConnectedPeer *cp = internal_cls;
1482  struct GSF_PeerTransmitHandle *pth;
1483  struct GSF_DelayedHandle *dh;
1484 
1485  if (NULL == cp)
1486  return; /* must have been disconnect from core with
1487  * 'peer' == my_id, ignore */
1488  flush_respect (NULL,
1489  peer,
1490  cp);
1493  peer,
1494  cp));
1496  gettext_noop ("# peers connected"),
1498  GNUNET_NO);
1499  if (NULL != cp->respect_iterate_req)
1500  {
1502  cp->respect_iterate_req = NULL;
1503  }
1504  if (NULL != cp->rc)
1505  {
1507  cp->rc = NULL;
1508  }
1509  if (NULL != cp->rc_delay_task)
1510  {
1512  cp->rc_delay_task = NULL;
1513  }
1516  cp);
1518  cp->request_map = NULL;
1523  memset (cp->ppd.last_p2p_replies,
1524  0,
1525  sizeof(cp->ppd.last_p2p_replies));
1526  GSF_push_stop_ (cp);
1527  while (NULL != (pth = cp->pth_head))
1528  {
1530  cp->pth_tail,
1531  pth);
1532  if (GNUNET_YES == pth->is_query)
1534  else if (GNUNET_NO == pth->is_query)
1536  GNUNET_free (pth);
1537  }
1538  while (NULL != (dh = cp->delayed_head))
1539  {
1541  cp->delayed_tail,
1542  dh);
1543  GNUNET_MQ_discard (dh->env);
1544  cp->delay_queue_size--;
1546  GNUNET_free (dh);
1547  }
1549  if (NULL != cp->mig_revive_task)
1550  {
1552  cp->mig_revive_task = NULL;
1553  }
1556  GNUNET_free (cp);
1557 }
static int flush_respect(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Write peer-respect information to a file - flush the buffer entry!
static int cancel_pending_request(void *cls, const struct GNUNET_HashCode *query, void *value)
Cancel all requests associated with the peer.
void GSF_plan_notify_peer_disconnect_(const struct GSF_ConnectedPeer *cp)
Notify the plan about a peer being no longer available; destroy all entries associated with this peer...
void GNUNET_ATS_reserve_bandwidth_cancel(struct GNUNET_ATS_ReservationContext *rc)
Cancel request for reserving bandwidth.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
enum GNUNET_GenericReturnValue 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.
#define GNUNET_LOAD_value_free(lv)
Free a load value.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:283
void GNUNET_PEER_decrement_rcs(const GNUNET_PEER_Id *ids, unsigned int count)
Decrement multiple RCs of peer identities by one.
Definition: peer.c:162
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:957
struct GSF_DelayedHandle * delayed_tail
Messages (replies, queries, content migration) we would like to send to this peer in the near future.
struct GSF_DelayedHandle * delayed_head
Messages (replies, queries, content migration) we would like to send to this peer in the near future.
struct GNUNET_SCHEDULER_Task * rc_delay_task
Task scheduled if we need to retry bandwidth reservation later.
Handle for an entry in our delay list.
struct GNUNET_SCHEDULER_Task * delay_task
Task for the delay.
struct GSF_ConnectedPeer * cp
Peer this transmission belongs to.
struct GNUNET_MQ_Envelope * env
Envelope of the message that was delayed.

References cancel_pending_request(), GSF_DelayedHandle::cp, cp_map, GSF_ConnectedPeer::delay_queue_size, GSF_DelayedHandle::delay_task, GSF_ConnectedPeer::delayed_head, GSF_ConnectedPeer::delayed_tail, GSF_DelayedHandle::env, flush_respect(), gettext_noop, GNUNET_assert, GNUNET_ATS_reserve_bandwidth_cancel(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_free, GNUNET_LOAD_value_free, GNUNET_MQ_discard(), GNUNET_NO, GNUNET_PEER_change_rc(), GNUNET_PEER_decrement_rcs(), GNUNET_PEERSTORE_iterate_cancel(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_YES, GSF_plan_notify_peer_disconnect_(), GSF_push_stop_(), GSF_stats, GSF_PeerTransmitHandle::is_query, GSF_PeerPerformanceData::last_p2p_replies, GSF_ConnectedPeer::mig_revive_task, P2P_SUCCESS_LIST_SIZE, peer, GSF_PeerPerformanceData::pending_queries, GSF_PeerPerformanceData::pending_replies, GSF_PeerPerformanceData::pid, GSF_ConnectedPeer::ppd, GSF_ConnectedPeer::pth_head, GSF_ConnectedPeer::pth_tail, GSF_ConnectedPeer::rc, GSF_ConnectedPeer::rc_delay_task, GSF_ConnectedPeer::request_map, GSF_ConnectedPeer::respect_iterate_req, and GSF_PeerPerformanceData::transmission_delay.

Referenced by main_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_handle_local_client_disconnect_()

void GSF_handle_local_client_disconnect_ ( const struct GSF_LocalClient lc)

Notification that a local client disconnected.

Clean up all of our references to the given handle.

Parameters
lchandle to the local client (henceforth invalid)

Definition at line 1787 of file gnunet-service-fs_cp.c.

1788 {
1789  if (NULL == cp_map)
1790  return; /* already cleaned up */
1793  (void *) lc);
1794 }
static int clean_local_client(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator to remove references to LC entry.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.

References clean_local_client(), cp_map, and GNUNET_CONTAINER_multipeermap_iterate().

Here is the call graph for this function:

◆ GSF_connected_peer_change_preference_()

void GSF_connected_peer_change_preference_ ( struct GSF_ConnectedPeer cp,
uint64_t  pref 
)

Notify core about a preference we have for the given peer (to allocate more resources towards it).

The change will be communicated the next time we reserve bandwidth with core (not instantly).

Parameters
cppeer to reserve bandwidth from
prefpreference change

Definition at line 1699 of file gnunet-service-fs_cp.c.

1701 {
1702  cp->inc_preference += pref;
1703 }
uint64_t inc_preference
Increase in traffic preference still to be submitted to the core service for this peer.

References GSF_ConnectedPeer::inc_preference.

Referenced by handle_p2p_put().

Here is the caller graph for this function:

◆ GSF_connected_peer_get_identity_()

void GSF_connected_peer_get_identity_ ( const struct GSF_ConnectedPeer cp,
struct GNUNET_PeerIdentity id 
)

Obtain the identity of a connected peer.

Parameters
cppeer to get identity of
ididentity to set (written to)

Definition at line 1621 of file gnunet-service-fs_cp.c.

1623 {
1624  GNUNET_assert (0 != cp->ppd.pid);
1625  GNUNET_PEER_resolve (cp->ppd.pid, id);
1626 }
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition: peer.c:225

References GNUNET_assert, GNUNET_PEER_resolve(), GSF_PeerPerformanceData::pid, and GSF_ConnectedPeer::ppd.

Referenced by consider_peer_for_forwarding().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_connected_peer_get_identity2_()

const struct GNUNET_PeerIdentity* GSF_connected_peer_get_identity2_ ( const struct GSF_ConnectedPeer cp)

Obtain the identity of a connected peer.

Parameters
cppeer to get identity of
Returns
reference to peer identity, valid until peer disconnects (!)

Definition at line 1636 of file gnunet-service-fs_cp.c.

1637 {
1638  GNUNET_assert (0 != cp->ppd.pid);
1639  return GNUNET_PEER_resolve2 (cp->ppd.pid);
1640 }
const struct GNUNET_PeerIdentity * GNUNET_PEER_resolve2(GNUNET_PEER_Id id)
Convert an interned PID to a normal peer identity.
Definition: peer.c:245

References GNUNET_assert, GNUNET_PEER_resolve2(), GSF_PeerPerformanceData::pid, and GSF_ConnectedPeer::ppd.

Referenced by GSF_peer_connect_handler(), GSF_plan_add_(), GSF_plan_notify_peer_disconnect_(), GSF_push_start_(), and process_migration_content().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_iterate_connected_peers_()

void GSF_iterate_connected_peers_ ( GSF_ConnectedPeerIterator  it,
void *  it_cls 
)

Iterate over all connected peers.

Parameters
itfunction to call for each peer
it_clsclosure for it

Definition at line 1601 of file gnunet-service-fs_cp.c.

1603 {
1604  struct IterationContext ic;
1605 
1606  ic.it = it;
1607  ic.it_cls = it_cls;
1609  &call_iterator,
1610  &ic);
1611 }
static int call_iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Function that calls the callback for each peer.
Closure for call_iterator().
void * it_cls
Closure for it.
GSF_ConnectedPeerIterator it
Function to call on each entry.

References call_iterator(), cp_map, GNUNET_CONTAINER_multipeermap_iterate(), IterationContext::it, and IterationContext::it_cls.

Referenced by GSF_consider_forwarding().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_connected_peer_init_()

void GSF_connected_peer_init_ ( void  )

Initialize peer management subsystem.

Definition at line 1729 of file gnunet-service-fs_cp.c.

1730 {
1734  &cron_flush_respect, NULL);
1735 }
const struct GNUNET_CONFIGURATION_Handle * GSF_cfg
Our configuration.
static void cron_flush_respect(void *cls)
Call this method periodically to flush respect information to disk.
static struct GNUNET_SCHEDULER_Task * fr_task
Task used to flush respect values to disk.
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).
@ GNUNET_SCHEDULER_PRIORITY_HIGH
Run with high priority (important requests).
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition: scheduler.c:1208

References cp_map, cron_flush_respect(), fr_task, GNUNET_CONTAINER_multipeermap_create(), GNUNET_PEERSTORE_connect(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_YES, GSF_cfg, and peerstore.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_connected_peer_done_()

void GSF_connected_peer_done_ ( void  )

Shutdown peer management subsystem.

Definition at line 1742 of file gnunet-service-fs_cp.c.

1743 {
1745  &flush_respect,
1746  NULL);
1748  fr_task = NULL;
1750  cp_map = NULL;
1752  GNUNET_YES);
1753 }
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h, int sync_first)
Disconnect from the PEERSTORE service.

References cp_map, flush_respect(), fr_task, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_PEERSTORE_disconnect(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, and peerstore.

Referenced by shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function: