GNUnet  0.10.x
Data Structures | Macros | Enumerations | Functions | Variables
gnunet-service-testbed_oc.c File Reference

code for handling overlay connect operations More...

#include "gnunet-service-testbed.h"
#include "gnunet-service-testbed_connectionpool.h"
#include "gnunet_transport_hello_service.h"
Include dependency graph for gnunet-service-testbed_oc.c:

Go to the source code of this file.

Data Structures

struct  ConnectivitySuggestContext
 Context information for requesting ATS to connect to a peer. More...
 
struct  LocalPeer2Context
 Context data for operations on second peer in local overlay connection contexts. More...
 
struct  RemotePeer2Context
 Context data for operations on second peer in remote overlay connection contexts. More...
 
struct  OverlayConnectContext
 Context information for connecting 2 peers in overlay. More...
 
struct  RemoteOverlayConnectCtx
 Context information for remote overlay connect operations. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "testbed-OC", __VA_ARGS__)
 Redefine LOG with a changed log component string. More...
 
#define PEER_EXPIRED(peer)   ( (GNUNET_YES == peer->destroy_flag) && (0 == peer->reference_cnt) )
 Condition for checking if given peer is ready to be destroyed. More...
 

Enumerations

enum  OverlayConnectContextType { OCC_TYPE_LOCAL, OCC_TYPE_REMOTE_SLAVE, OCC_TYPE_REMOTE_LATERAL }
 Types for context information we create for overlay connect requests. More...
 

Functions

void GST_cleanup_focc (struct ForwardedOverlayConnectContext *focc)
 Cleans up ForwardedOverlayConnectContext. More...
 
static void forwarded_overlay_connect_timeout (void *cls)
 Timeout task for cancelling a forwarded overlay connect connect. More...
 
static void forwarded_overlay_connect_listener (void *cls, const struct GNUNET_MessageHeader *msg)
 Callback to be called when forwarded overlay connection operation has a reply from the sub-controller successfull. More...
 
void GST_process_next_focc (struct RegisteredHostContext *rhc)
 Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext. More...
 
static void cleanup_occ_lp2c (struct LocalPeer2Context *lp2c)
 Cleans up any used handles in local peer2 context. More...
 
static void cleanup_occ_rp2c (struct RemotePeer2Context *rp2c)
 Cleans up any used handles in remote peer2 context. More...
 
static void cleanup_occ (struct OverlayConnectContext *occ)
 Cleanup overlay connect context structure. More...
 
static void do_cleanup_occ (void *cls)
 Task for cleaing up overlay connect context structure. More...
 
static void timeout_overlay_connect (void *cls)
 Task which will be run when overlay connect request has been timed out. More...
 
void GST_notify_client_disconnect_oc (struct GNUNET_SERVICE_Client *client)
 Notify OC subsystem that client disconnected. More...
 
static void send_overlay_connect_success_msg (struct OverlayConnectContext *occ)
 FIXME. More...
 
static void overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer)
 Function called to notify transport users that another peer connected to us. More...
 
static void occ_cache_get_handle_ats_occ_cb (void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Callback from cache with needed ATS handle set. More...
 
static void occ_cache_get_handle_ats_rocc_cb (void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Callback from cache with needed ATS handle set. More...
 
static void send_hello (void *cls)
 Task to offer HELLO of peer 1 to peer 2 and try to make peer 2 to connect to peer 1. More...
 
static void occ_hello_sent_cb (void *cls)
 Task that is run when hello has been sent If tc->reason = GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if GNUNET_SCHEDULER_REASON_READ_READY is succeeded. More...
 
static void send_hello_thru_rocc (struct OverlayConnectContext *occ)
 Sends the HELLO of peer1 to peer2's controller through remote overlay connect request. More...
 
static void p2_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *ignore_, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Callback from cache with needed handles set. More...
 
static void p2_transport_connect (struct OverlayConnectContext *occ)
 Connects to the transport of the other peer if it is a local peer and schedules the send hello task. More...
 
static int test_address (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
 Test for checking whether HELLO message is empty. More...
 
static void hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
 Function called whenever there is an update to the HELLO of peers in the OverlayConnectClosure. More...
 
static void p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *ignore_, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Callback from cache with needed handles set. More...
 
static void occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Callback from cache with needed CORE handle set. More...
 
static void overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg)
 Callback to be called when forwarded get peer config operation as part of overlay connect is successfull. More...
 
static void host_registration_comp (void *cls, const char *emsg)
 Callback which will be called after a host registration succeeded or failed. More...
 
static int reghost_match_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
 Iterator to match a registered host context. More...
 
static struct GNUNET_HashCode hash_hosts (struct GNUNET_TESTBED_Host *reg_host, struct GNUNET_TESTBED_Host *host)
 Function to generate the hashcode corresponding to a RegisteredHostContext. More...
 
static struct RegisteredHostContextregister_host (struct Slave *slave, struct GNUNET_TESTBED_Host *host)
 Checks if the given host is registered at the given slave. More...
 
static void forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, struct GNUNET_SERVICE_Client *client)
 Forwards the overlay connect request to a slave controller. More...
 
static void p2_controller_connect_cb (void *cls, struct GNUNET_TESTBED_Controller *c)
 Callback called when a connection to the controller of peer2 has been established. More...
 
void handle_overlay_connect (void *cls, const struct GNUNET_TESTBED_OverlayConnectMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT messages. More...
 
static void cleanup_rocc (struct RemoteOverlayConnectCtx *rocc)
 Function to cleanup RemoteOverlayConnectCtx and any associated tasks with it. More...
 
static void timeout_rocc_task (void *cls)
 Task to timeout rocc and cleanit up. More...
 
static void cache_transport_peer_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer)
 Function called to notify transport users that another peer connected to us. More...
 
static void attempt_connect_task (void *cls)
 Task to offer the HELLO message to the peer and ask it to connect to the peer whose identity is in RemoteOverlayConnectCtx. More...
 
static void rocc_hello_sent_cb (void *cls)
 Task that is run when hello has been sent If tc->reason = GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if GNUNET_SCHEDULER_REASON_READ_READY is succeeded. More...
 
static void rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *ignore_, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Callback from cache with needed handles set. More...
 
int check_remote_overlay_connect (void *cls, const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg)
 Check GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages. More...
 
void handle_remote_overlay_connect (void *cls, const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages. More...
 
void GST_free_occq ()
 Clears all pending overlay connect contexts in queue. More...
 
void GST_free_roccq ()
 Clears all pending remote overlay connect contexts in queue. More...
 

Variables

static struct OverlayConnectContextoccq_head
 DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown. More...
 
static struct OverlayConnectContextoccq_tail
 DLL tail for OverlayConnectContext DLL. More...
 
static struct RemoteOverlayConnectCtxroccq_head
 DLL head for RequectOverlayConnectContext DLL - to be used to clean up during shutdown. More...
 
static struct RemoteOverlayConnectCtxroccq_tail
 DLL tail for RequectOverlayConnectContext DLL. More...
 

Detailed Description

code for handling overlay connect operations

Author
Sree Harsha Totakura

Definition in file gnunet-service-testbed_oc.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "testbed-OC", __VA_ARGS__)

Redefine LOG with a changed log component string.

Definition at line 37 of file gnunet-service-testbed_oc.c.

Referenced by handle_overlay_connect().

◆ PEER_EXPIRED

#define PEER_EXPIRED (   peer)    ( (GNUNET_YES == peer->destroy_flag) && (0 == peer->reference_cnt) )

Condition for checking if given peer is ready to be destroyed.

Parameters
peerthe peer to check

Definition at line 525 of file gnunet-service-testbed_oc.c.

Referenced by cleanup_occ().

Enumeration Type Documentation

◆ OverlayConnectContextType

Types for context information we create for overlay connect requests.

Enumerator
OCC_TYPE_LOCAL 

This type is used if the overlay connection is local i.e.

the connection has to be made between local peers

OCC_TYPE_REMOTE_SLAVE 

Type to be used when the first peer is local and the other peer is on a slave controller started by us.

OCC_TYPE_REMOTE_LATERAL 

Type to be used when the first peer is local and the other peer is on a controller which is not started by us.

Definition at line 79 of file gnunet-service-testbed_oc.c.

80 {
86 
92 
98 };
Type to be used when the first peer is local and the other peer is on a controller which is not start...
This type is used if the overlay connection is local i.e.
Type to be used when the first peer is local and the other peer is on a slave controller started by u...

Function Documentation

◆ GST_cleanup_focc()

void GST_cleanup_focc ( struct ForwardedOverlayConnectContext focc)

Cleans up ForwardedOverlayConnectContext.

Parameters
foccthe ForwardedOverlayConnectContext to cleanup

Definition at line 359 of file gnunet-service-testbed_oc.c.

References RegisteredHostContext::focc_dll_head, RegisteredHostContext::focc_dll_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_non_null, ForwardedOverlayConnectContext::orig_msg, and ForwardedOverlayConnectContext::rhc.

Referenced by drop_client_entries(), forwarded_overlay_connect_listener(), forwarded_overlay_connect_timeout(), and reghost_free_iterator().

360 {
361  struct RegisteredHostContext *rhc = focc->rhc;
362 
364  rhc->focc_dll_tail,
365  focc);
367  GNUNET_free (focc);
368 }
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
This context information will be created for each host that is registered at slave controllers during...
struct GNUNET_MessageHeader * orig_msg
A copy of the original overlay connect message.
struct ForwardedOverlayConnectContext * focc_dll_tail
Tail of the ForwardedOverlayConnectContext DLL.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct RegisteredHostContext * rhc
Which host does this FOCC belong to?
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ forwarded_overlay_connect_timeout()

static void forwarded_overlay_connect_timeout ( void *  cls)
static

Timeout task for cancelling a forwarded overlay connect connect.

Parameters
clsthe struct ForwardedOperationContext

Definition at line 377 of file gnunet-service-testbed_oc.c.

References ForwardedOperationContext::cls, RegisteredHostContext::focc_dll_head, GST_cleanup_focc(), GST_forwarded_operation_timeout(), GST_process_next_focc(), LOG_DEBUG, ForwardedOverlayConnectContext::peer1, ForwardedOverlayConnectContext::peer2, and ForwardedOperationContext::timeout_task.

Referenced by GST_process_next_focc().

378 {
379  struct ForwardedOperationContext *fopc = cls;
380  struct RegisteredHostContext *rhc;
381  struct ForwardedOverlayConnectContext *focc;
382 
383  fopc->timeout_task = NULL;
384  rhc = fopc->cls;
385  focc = rhc->focc_dll_head;
386  LOG_DEBUG ("Overlay linking between peers %u and %u failed\n",
387  focc->peer1,
388  focc->peer2);
389  GST_cleanup_focc (focc);
391  if (NULL != rhc->focc_dll_head)
392  GST_process_next_focc (rhc);
393 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
This context information will be created for each host that is registered at slave controllers during...
void GST_cleanup_focc(struct ForwardedOverlayConnectContext *focc)
Cleans up ForwardedOverlayConnectContext.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
uint32_t peer2
The id of peer 2.
Context information to used during operations which forward the overlay connect message.
void * cls
Closure pointer.
void GST_process_next_focc(struct RegisteredHostContext *rhc)
Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext.
#define LOG_DEBUG(msg)
Context information for operations forwarded to subcontrollers.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ forwarded_overlay_connect_listener()

static void forwarded_overlay_connect_listener ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Callback to be called when forwarded overlay connection operation has a reply from the sub-controller successfull.

We have to relay the reply msg back to the client

Parameters
clsForwardedOperationContext
msgthe peer create success message

Definition at line 405 of file gnunet-service-testbed_oc.c.

References ForwardedOperationContext::cls, RegisteredHostContext::focc_dll_head, GST_cleanup_focc(), GST_forwarded_operation_reply_relay(), and GST_process_next_focc().

Referenced by GST_process_next_focc().

407 {
408  struct ForwardedOperationContext *fopc = cls;
409  struct RegisteredHostContext *rhc;
410  struct ForwardedOverlayConnectContext *focc;
411 
412  rhc = fopc->cls;
414  focc = rhc->focc_dll_head;
415  GST_cleanup_focc (focc);
416  if (NULL != rhc->focc_dll_head)
417  GST_process_next_focc (rhc);
418 }
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
This context information will be created for each host that is registered at slave controllers during...
void GST_cleanup_focc(struct ForwardedOverlayConnectContext *focc)
Cleans up ForwardedOverlayConnectContext.
void GST_forwarded_operation_reply_relay(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to relay the reply msg of a forwarded operation back to the client.
Context information to used during operations which forward the overlay connect message.
void * cls
Closure pointer.
void GST_process_next_focc(struct RegisteredHostContext *rhc)
Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext.
Context information for operations forwarded to subcontrollers.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_process_next_focc()

void GST_process_next_focc ( struct RegisteredHostContext rhc)

Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext.

Parameters
rhcthe RegisteredHostContext

Definition at line 427 of file gnunet-service-testbed_oc.c.

References ForwardedOperationContext::client, ForwardedOverlayConnectContext::client, ForwardedOperationContext::cls, Slave::controller, Peer::details, RegisteredHostContext::focc_dll_head, fopcq_head, fopcq_tail, forwarded_overlay_connect_listener(), forwarded_overlay_connect_timeout(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_free, GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_YES, GST_peer_list, GST_timeout, Peer::is_remote, OP_OVERLAY_CONNECT, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, ForwardedOverlayConnectContext::operation_id, ForwardedOverlayConnectContext::orig_msg, peer, ForwardedOverlayConnectContext::peer1, Peer::remote, RegisteredHostContext::state, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

Referenced by forwarded_overlay_connect_listener(), forwarded_overlay_connect_timeout(), and host_registration_comp().

428 {
429  struct ForwardedOperationContext *fopc;
430  struct ForwardedOverlayConnectContext *focc;
431  struct Peer *peer;
432  struct Slave *slave;
433 
434  focc = rhc->focc_dll_head;
435  GNUNET_assert (NULL != focc);
436  GNUNET_assert (RHC_DONE == rhc->state);
438  peer = GST_peer_list[focc->peer1];
440  GNUNET_assert (NULL != (slave = peer->details.remote.slave));
441  fopc = GNUNET_new (struct ForwardedOperationContext);
442  fopc->client = focc->client;
443  fopc->operation_id = focc->operation_id;
444  fopc->cls = rhc;
445  fopc->type = OP_OVERLAY_CONNECT;
446  fopc->opc =
448  focc->operation_id,
449  focc->orig_msg,
451  fopc);
452  GNUNET_free (focc->orig_msg);
453  focc->orig_msg = NULL;
456  fopc);
458  fopcq_tail,
459  fopc);
460 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
static void forwarded_overlay_connect_listener(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded overlay connection operation has a reply from the sub-controller...
int is_remote
Is this peer locally created?
struct GNUNET_MessageHeader * orig_msg
A copy of the original overlay connect message.
struct Peer::@69::@71 remote
static void forwarded_overlay_connect_timeout(void *cls)
Timeout task for cancelling a forwarded overlay connect connect.
struct GNUNET_SERVICE_Client * client
The client handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct OperationContext * opc
The generated operation context.
struct Peer ** GST_peer_list
A list of peers we know about.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Structure representing a connected(directly-linked) controller.
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:1246
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
uint64_t operation_id
The id of the operation which created this context information.
enum OperationType type
The type of the operation which is forwarded.
Context information to used during operations which forward the overlay connect message.
enum RegisteredHostContext::RHCState state
void * cls
Closure pointer.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Overlay connection operation.
Definition: testbed_api.h:79
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct OperationContext * GNUNET_TESTBED_forward_operation_msg_(struct GNUNET_TESTBED_Controller *controller, uint64_t operation_id, const struct GNUNET_MessageHeader *msg, GNUNET_MQ_MessageCallback cc, void *cc_cls)
Sends the given message as an operation.
Definition: testbed_api.c:1349
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
union Peer::@69 details
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
uint64_t operation_id
The id of the operation that has been forwarded.
#define GNUNET_YES
Definition: gnunet_common.h:80
Context information for operations forwarded to subcontrollers.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_occ_lp2c()

static void cleanup_occ_lp2c ( struct LocalPeer2Context lp2c)
static

Cleans up any used handles in local peer2 context.

Parameters
lp2cthe local peer2 context information

Definition at line 469 of file gnunet-service-testbed_oc.c.

References ConnectivitySuggestContext::cgh_p2_ats, ConnectivitySuggestContext::cgh_p2_th, ConnectivitySuggestContext::csh, GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_TRANSPORT_offer_hello_cancel(), GST_connection_pool_get_handle_done(), LocalPeer2Context::ohh, and LocalPeer2Context::tcc.

Referenced by cleanup_occ(), and overlay_connect_notify().

470 {
471  if (NULL != lp2c->ohh)
472  {
474  lp2c->ohh = NULL;
475  }
476  if (NULL != lp2c->tcc.cgh_p2_th)
477  {
479  lp2c->tcc.cgh_p2_th = NULL;
480  }
481  if (NULL != lp2c->tcc.cgh_p2_ats)
482  {
484  lp2c->tcc.cgh_p2_ats = NULL;
485  }
486  if (NULL != lp2c->tcc.csh)
487  {
489  lp2c->tcc.csh = NULL;
490  }
491 }
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
The handle for offering the HELLO of the first peer to the second peer.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
void GNUNET_TRANSPORT_offer_hello_cancel(struct GNUNET_TRANSPORT_OfferHelloHandle *ohh)
Cancel the request to transport to offer the HELLO message.
struct GNUNET_ATS_ConnectivitySuggestHandle * csh
The ATS handle for the connectivity suggestion.
struct GST_ConnectionPool_GetHandle * cgh_p2_th
The GetCacheHandle for the peer2's transport handle (used to offer the HELLO to the peer)...
void GST_connection_pool_get_handle_done(struct GST_ConnectionPool_GetHandle *gh)
Relinquish a GST_ConnectionPool_GetHandle object.
struct GST_ConnectionPool_GetHandle * cgh_p2_ats
The GetCacheHandle for the peer2's ATS handle.
struct ConnectivitySuggestContext tcc
The transport ConnectivitySuggestContext.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_occ_rp2c()

static void cleanup_occ_rp2c ( struct RemotePeer2Context rp2c)
static

Cleans up any used handles in remote peer2 context.

Relinquishes the remote controller connection if it has been established on-demand.

Parameters
rp2cthe remote peer2 context information

Definition at line 501 of file gnunet-service-testbed_oc.c.

References GNUNET_TESTBED_forward_operation_msg_cancel_(), GST_neighbour_get_connection_cancel(), GST_neighbour_release_connection(), RemotePeer2Context::ncn, RemotePeer2Context::opc, RemotePeer2Context::p2c, and RemotePeer2Context::p2n.

Referenced by cleanup_occ(), and overlay_connect_notify().

502 {
503  if (NULL != rp2c->opc)
504  {
506  rp2c->opc = NULL;
507  }
508  if (NULL != rp2c->ncn)
509  {
511  rp2c->ncn = NULL;
512  }
513  if ( (NULL != rp2c->p2c) && (NULL != rp2c->p2n) )
514  {
516  rp2c->p2n = NULL;
517  }
518 }
struct NeighbourConnectNotification * ncn
Notification handle acquire to connect to a remote controller.
struct GNUNET_TESTBED_Controller * p2c
Controller of peer 2; If OCC_TYPE_REMOTE_LATERAL is the type of overlay connection then this can be N...
void GNUNET_TESTBED_forward_operation_msg_cancel_(struct OperationContext *opc)
Function to cancel an operation created by simply forwarding an operation message.
Definition: testbed_api.c:1386
struct Neighbour * p2n
The neighbour handle.
struct OperationContext * opc
Operation context for the suboperation we start to get the identity of the second peer...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_occ()

static void cleanup_occ ( struct OverlayConnectContext occ)
static

Cleanup overlay connect context structure.

Parameters
occthe overlay connect context

Definition at line 534 of file gnunet-service-testbed_oc.c.

References OverlayConnectContext::cgh_ch, OverlayConnectContext::cgh_p1th, cleanup_occ_lp2c(), cleanup_occ_rp2c(), OverlayConnectContext::cleanup_task, OverlayConnectContext::emsg, OverlayConnectContext::ghh, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_non_null, GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_hello_get_cancel(), GST_connection_pool_get_handle_done(), GST_destroy_peer(), GST_peer_list, OverlayConnectContext::hello, OverlayConnectContext::local, LOG_DEBUG, OCC_TYPE_LOCAL, OCC_TYPE_REMOTE_LATERAL, OCC_TYPE_REMOTE_SLAVE, OverlayConnectContext::op_id, OverlayConnectContext::other_peer_id, OverlayConnectContext::p2ctx, OverlayConnectContext::peer, PEER_EXPIRED, Peer::reference_cnt, OverlayConnectContext::remote, OverlayConnectContext::send_hello_task, OverlayConnectContext::timeout_task, and OverlayConnectContext::type.

Referenced by do_cleanup_occ(), GST_free_occq(), GST_notify_client_disconnect_oc(), and timeout_overlay_connect().

535 {
536  struct Peer *peer2;
537 
538  LOG_DEBUG ("0x%llx: Cleaning up occ\n",
539  occ->op_id);
540  GNUNET_free_non_null (occ->emsg);
542  if (NULL != occ->send_hello_task)
544  if (NULL != occ->cleanup_task)
546  if (NULL != occ->timeout_task)
548  if (NULL != occ->cgh_ch)
550  if (NULL != occ->ghh)
553  GNUNET_assert (NULL != GST_peer_list);
554  GNUNET_assert (occ->peer->reference_cnt > 0);
555  occ->peer->reference_cnt--;
556  if (PEER_EXPIRED (occ->peer))
557  GST_destroy_peer (occ->peer);
558  switch (occ->type)
559  {
560  case OCC_TYPE_LOCAL:
561  peer2 = GST_peer_list[occ->other_peer_id];
562  GNUNET_assert (peer2->reference_cnt > 0);
563  peer2->reference_cnt--;
564  if (PEER_EXPIRED (peer2))
565  GST_destroy_peer (peer2);
566  cleanup_occ_lp2c (&occ->p2ctx.local);
567  break;
570  cleanup_occ_rp2c (&occ->p2ctx.remote);
571  break;
572  }
574  occq_tail,
575  occ);
576  GNUNET_free (occ);
577 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
uint64_t op_id
The id of the operation responsible for creating this context.
Type to be used when the first peer is local and the other peer is on a controller which is not start...
struct GST_ConnectionPool_GetHandle * cgh_ch
The GST_ConnectionPool_GetHandle for registering callback to notify CORE level peer connects and to g...
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct Peer ** GST_peer_list
A list of peers we know about.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct RemotePeer2Context remote
Context information to be used if the second peer is remote.
struct GST_ConnectionPool_GetHandle * cgh_p1th
The GST_ConnectionPool_GetHandle for the peer1's transport handle.
char * emsg
The error message we send if this overlay connect operation has timed out.
static struct OverlayConnectContext * occq_tail
DLL tail for OverlayConnectContext DLL.
struct Peer * peer
the first peer which is to expect an overlay connection from the second peer.
struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Get GetHelloHandle to acquire a HELLO of the first peer.
enum OverlayConnectContextType type
The type of this context information.
struct LocalPeer2Context local
Context information to be used if the second peer is local.
struct GNUNET_MessageHeader * hello
HELLO of the first peer.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
This type is used if the overlay connection is local i.e.
static struct OverlayConnectContext * occq_head
DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown.
struct GNUNET_SCHEDULER_Task * send_hello_task
The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to connect to peer 2...
Type to be used when the first peer is local and the other peer is on a slave controller started by u...
uint32_t other_peer_id
The id of the second peer which has to connect to the first peer.
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
Information about preferences and sessions we track per peer.
#define PEER_EXPIRED(peer)
Condition for checking if given peer is ready to be destroyed.
struct GNUNET_SCHEDULER_Task * cleanup_task
The id of the cleanup task.
static void cleanup_occ_lp2c(struct LocalPeer2Context *lp2c)
Cleans up any used handles in local peer2 context.
#define LOG_DEBUG(msg)
void GST_connection_pool_get_handle_done(struct GST_ConnectionPool_GetHandle *gh)
Relinquish a GST_ConnectionPool_GetHandle object.
static void cleanup_occ_rp2c(struct RemotePeer2Context *rp2c)
Cleans up any used handles in remote peer2 context.
void GNUNET_TRANSPORT_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
Stop receiving updates about changes to our HELLO message.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_cleanup_occ()

static void do_cleanup_occ ( void *  cls)
static

Task for cleaing up overlay connect context structure.

Parameters
clsthe overlay connect context

Definition at line 586 of file gnunet-service-testbed_oc.c.

References cleanup_occ(), and OverlayConnectContext::cleanup_task.

Referenced by occ_cache_get_handle_core_cb(), and overlay_connect_notify().

587 {
588  struct OverlayConnectContext *occ = cls;
589 
590  occ->cleanup_task = NULL;
591  cleanup_occ (occ);
592 }
Context information for connecting 2 peers in overlay.
static void cleanup_occ(struct OverlayConnectContext *occ)
Cleanup overlay connect context structure.
struct GNUNET_SCHEDULER_Task * cleanup_task
The id of the cleanup task.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeout_overlay_connect()

static void timeout_overlay_connect ( void *  cls)
static

Task which will be run when overlay connect request has been timed out.

Parameters
clsthe OverlayConnectContext

Definition at line 601 of file gnunet-service-testbed_oc.c.

References cleanup_occ(), OverlayConnectContext::client, OverlayConnectContext::emsg, GNUNET_assert, GST_send_operation_fail_msg(), OverlayConnectContext::op_id, and OverlayConnectContext::timeout_task.

Referenced by handle_overlay_connect(), occ_cache_get_handle_ats_occ_cb(), occ_cache_get_handle_core_cb(), overlay_connect_get_config(), p1_transport_connect_cache_callback(), and p2_transport_connect_cache_callback().

602 {
603  struct OverlayConnectContext *occ = cls;
604 
605  GNUNET_assert (NULL != occ->timeout_task);
606  occ->timeout_task = NULL;
607  /* LOG (GNUNET_ERROR_TYPE_WARNING, */
608  /* "0x%llx: Timeout while connecting peers %u and %u: %s\n", occ->op_id, */
609  /* occ->peer->id, occ->other_peer_id, occ->emsg); */
611  occ->op_id,
612  occ->emsg);
613  cleanup_occ (occ);
614 }
uint64_t op_id
The id of the operation responsible for creating this context.
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
char * emsg
The error message we send if this overlay connect operation has timed out.
struct GNUNET_SERVICE_Client * client
The client which has requested for overlay connection.
static void cleanup_occ(struct OverlayConnectContext *occ)
Cleanup overlay connect context structure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_notify_client_disconnect_oc()

void GST_notify_client_disconnect_oc ( struct GNUNET_SERVICE_Client client)

Notify OC subsystem that client disconnected.

Parameters
clientthe client that disconnected

Definition at line 623 of file gnunet-service-testbed_oc.c.

References cleanup_occ(), ForwardedOperationContext::client, OverlayConnectContext::client, fopcq_head, GNUNET_SCHEDULER_cancel(), GST_forwarded_operation_timeout(), ForwardedOperationContext::next, OverlayConnectContext::next, and ForwardedOperationContext::timeout_task.

Referenced by client_disconnect_cb().

624 {
625  struct ForwardedOperationContext *fopc;
626  struct ForwardedOperationContext *fopcn;
627  struct OverlayConnectContext *occ;
628  struct OverlayConnectContext *occn;
629 
630  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
631  {
632  fopcn = fopc->next;
633  if (fopc->client == client)
634  {
637  }
638  }
639  for (occ = occq_head; NULL != occ; occ = occn)
640  {
641  occn = occ->next;
642  if (occ->client == client)
643  cleanup_occ (occ);
644  }
645  // FIXME: implement clean up for client_keep replacements!
646 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
Context information for connecting 2 peers in overlay.
struct OverlayConnectContext * next
The next pointer for maintaining a DLL of all OverlayConnectContexts.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
struct GNUNET_SERVICE_Client * client
The client which has requested for overlay connection.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
static void cleanup_occ(struct OverlayConnectContext *occ)
Cleanup overlay connect context structure.
static struct OverlayConnectContext * occq_head
DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
struct ForwardedOperationContext * next
The next pointer for DLL.
Context information for operations forwarded to subcontrollers.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_overlay_connect_success_msg()

static void send_overlay_connect_success_msg ( struct OverlayConnectContext occ)
static

FIXME.

Definition at line 655 of file gnunet-service-testbed_oc.c.

References OverlayConnectContext::client, env, GNUNET_TESTBED_ConnectionEventMessage::event_type, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_CONNECT, Peer::id, LOG_DEBUG, msg, OverlayConnectContext::op_id, GNUNET_TESTBED_ConnectionEventMessage::operation_id, OverlayConnectContext::other_peer_id, OverlayConnectContext::peer, GNUNET_TESTBED_ConnectionEventMessage::peer1, and GNUNET_TESTBED_ConnectionEventMessage::peer2.

Referenced by occ_cache_get_handle_core_cb(), and overlay_connect_notify().

656 {
657  struct GNUNET_MQ_Envelope *env;
659 
660  LOG_DEBUG ("0x%llx: Peers connected - Sending overlay connect success\n",
661  occ->op_id);
662  env = GNUNET_MQ_msg (msg,
664  msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT);
665  msg->peer1 = htonl (occ->peer->id);
666  msg->peer2 = htonl (occ->other_peer_id);
667  msg->operation_id = GNUNET_htonll (occ->op_id);
669  env);
670 }
uint64_t op_id
The id of the operation responsible for creating this context.
Event notification from a controller to a client.
Definition: testbed.h:501
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT
Message for peer connect events.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
uint32_t id
Our local reference id for this peer.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_SERVICE_Client * client
The client which has requested for overlay connection.
struct Peer * peer
the first peer which is to expect an overlay connection from the second peer.
uint32_t peer2
Second peer.
Definition: testbed.h:523
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:528
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
uint32_t peer1
First peer.
Definition: testbed.h:518
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
int32_t event_type
'enum GNUNET_TESTBED_EventType' (in NBO); either GNUNET_TESTBED_ET_CONNECT or GNUNET_TESTBED_ET_DISCO...
Definition: testbed.h:513
A connection between two peers was established.
uint32_t other_peer_id
The id of the second peer which has to connect to the first peer.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define LOG_DEBUG(msg)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ overlay_connect_notify()

static void overlay_connect_notify ( void *  cls,
const struct GNUNET_PeerIdentity new_peer 
)
static

Function called to notify transport users that another peer connected to us.

Parameters
clsclosure
new_peerthe peer that connected

Definition at line 681 of file gnunet-service-testbed_oc.c.

References cleanup_occ_lp2c(), cleanup_occ_rp2c(), OverlayConnectContext::cleanup_task, do_cleanup_occ(), OverlayConnectContext::emsg, GNUNET_assert, GNUNET_free, GNUNET_free_non_null, GNUNET_i2s(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_strdup, OverlayConnectContext::local, LOG_DEBUG, OCC_TYPE_LOCAL, OCC_TYPE_REMOTE_LATERAL, OCC_TYPE_REMOTE_SLAVE, OverlayConnectContext::op_id, OverlayConnectContext::other_peer_identity, OverlayConnectContext::p2ctx, OverlayConnectContext::peer_identity, OverlayConnectContext::remote, OverlayConnectContext::send_hello_task, send_overlay_connect_success_msg(), OverlayConnectContext::timeout_task, and OverlayConnectContext::type.

Referenced by handle_overlay_connect(), and overlay_connect_get_config().

683 {
684  struct OverlayConnectContext *occ = cls;
685  char *new_peer_str;
686  char *other_peer_str;
687 
688  LOG_DEBUG ("Overlay connect notify\n");
689  if (0 ==
690  memcmp (new_peer, &occ->peer_identity,
691  sizeof (struct GNUNET_PeerIdentity)))
692  return;
693  new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer));
694  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
695  if (0 !=
696  memcmp (new_peer,
697  &occ->other_peer_identity,
698  sizeof (struct GNUNET_PeerIdentity)))
699  {
700  LOG_DEBUG ("Unexpected peer %s connected when expecting peer %s\n",
701  new_peer_str,
702  other_peer_str);
703  GNUNET_free (new_peer_str);
704  GNUNET_free (other_peer_str);
705  return;
706  }
707  GNUNET_free (new_peer_str);
708  LOG_DEBUG ("0x%llx: Peer %s connected to peer %s\n",
709  occ->op_id,
710  other_peer_str,
711  GNUNET_i2s (&occ->peer_identity));
712  GNUNET_free (other_peer_str);
713  if (NULL != occ->send_hello_task)
714  {
716  occ->send_hello_task = NULL;
717  }
718  GNUNET_assert (NULL != occ->timeout_task);
720  occ->timeout_task = NULL;
721  switch (occ->type)
722  {
723  case OCC_TYPE_LOCAL:
724  cleanup_occ_lp2c (&occ->p2ctx.local);
725  break;
728  cleanup_occ_rp2c (&occ->p2ctx.remote);
729  break;
730  }
731  GNUNET_free_non_null (occ->emsg);
732  occ->emsg = NULL;
735  occ);
736 }
uint64_t op_id
The id of the operation responsible for creating this context.
Type to be used when the first peer is local and the other peer is on a controller which is not start...
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct RemotePeer2Context remote
Context information to be used if the second peer is remote.
char * emsg
The error message we send if this overlay connect operation has timed out.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
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.
Definition: scheduler.c:1273
enum OverlayConnectContextType type
The type of this context information.
struct LocalPeer2Context local
Context information to be used if the second peer is local.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
This type is used if the overlay connection is local i.e.
struct GNUNET_SCHEDULER_Task * send_hello_task
The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to connect to peer 2...
Type to be used when the first peer is local and the other peer is on a slave controller started by u...
static void send_overlay_connect_success_msg(struct OverlayConnectContext *occ)
FIXME.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_PeerIdentity peer_identity
The peer identity of the first peer.
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
struct GNUNET_SCHEDULER_Task * cleanup_task
The id of the cleanup task.
static void cleanup_occ_lp2c(struct LocalPeer2Context *lp2c)
Cleans up any used handles in local peer2 context.
#define LOG_DEBUG(msg)
static void cleanup_occ_rp2c(struct RemotePeer2Context *rp2c)
Cleans up any used handles in remote peer2 context.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static void do_cleanup_occ(void *cls)
Task for cleaing up overlay connect context structure.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ occ_cache_get_handle_ats_occ_cb()

static void occ_cache_get_handle_ats_occ_cb ( void *  cls,
struct GNUNET_CORE_Handle ch,
struct GNUNET_TRANSPORT_CoreHandle th,
struct GNUNET_ATS_ConnectivityHandle ac,
const struct GNUNET_PeerIdentity my_identity,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Callback from cache with needed ATS handle set.

Parameters
clsa struct OverlayConnectCtx *
chthe handle to CORE. Can be NULL if it is not requested
ththe handle to TRANSPORT. Can be NULL if it is not requested
acthe handle to ATS. Can be NULL if it is not requested
my_identitythe identity of our peer
cfgconfiguration of the peer

Definition at line 750 of file gnunet-service-testbed_oc.c.

References ConnectivitySuggestContext::csh, OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_ATS_connectivity_suggest(), GNUNET_free_non_null, GNUNET_i2s(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), Peer::id, OverlayConnectContext::local, OCC_TYPE_LOCAL, OverlayConnectContext::op_id, OverlayConnectContext::other_peer_identity, OverlayConnectContext::p2ctx, OverlayConnectContext::peer, OverlayConnectContext::peer_identity, LocalPeer2Context::tcc, timeout_overlay_connect(), OverlayConnectContext::timeout_task, and OverlayConnectContext::type.

Referenced by occ_hello_sent_cb().

756 {
757  struct OverlayConnectContext *occ = cls;
758  struct LocalPeer2Context *lp2c;
759 
761  GNUNET_assert (NULL != occ->timeout_task);
762  GNUNET_free_non_null (occ->emsg);
763  if (NULL == ac)
764  {
765  GNUNET_asprintf (&occ->emsg,
766  "0x%llx: Failed to connect to ATS of peer with id: %u",
767  occ->op_id,
768  occ->peer->id);
770  occ->timeout_task =
772  occ);
773  return;
774  }
775  occ->emsg = NULL;
776 
777  GNUNET_asprintf (&occ->emsg,
778  "0x%llx: Timeout during GNUNET_ATS_connectivity_suggest() at peer %s",
779  occ->op_id,
781 
782  lp2c = &occ->p2ctx.local;
783  lp2c->tcc.csh =
785  &occ->peer_identity,
786  1);
787 }
uint64_t op_id
The id of the operation responsible for creating this context.
Context data for operations on second peer in local overlay connection contexts.
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Our local reference id for this peer.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
char * emsg
The error message we send if this overlay connect operation has timed out.
static void timeout_overlay_connect(void *cls)
Task which will be run when overlay connect request has been timed out.
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.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct Peer * peer
the first peer which is to expect an overlay connection from the second peer.
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.
Definition: scheduler.c:1273
enum OverlayConnectContextType type
The type of this context information.
struct LocalPeer2Context local
Context information to be used if the second peer is local.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
This type is used if the overlay connection is local i.e.
struct GNUNET_ATS_ConnectivitySuggestHandle * csh
The ATS handle for the connectivity suggestion.
struct GNUNET_PeerIdentity peer_identity
The peer identity of the first peer.
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
struct ConnectivitySuggestContext tcc
The transport ConnectivitySuggestContext.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ occ_cache_get_handle_ats_rocc_cb()

static void occ_cache_get_handle_ats_rocc_cb ( void *  cls,
struct GNUNET_CORE_Handle ch,
struct GNUNET_TRANSPORT_CoreHandle th,
struct GNUNET_ATS_ConnectivityHandle ac,
const struct GNUNET_PeerIdentity my_identity,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Callback from cache with needed ATS handle set.

Parameters
clsa struct RemoteOverlayConnectCtx *
chthe handle to CORE. Can be NULL if it is not requested
ththe handle to TRANSPORT. Can be NULL if it is not requested
acthe handle to ATS. Can be NULL if it is not requested
my_identitythe identity of our peer

Definition at line 800 of file gnunet-service-testbed_oc.c.

References RemoteOverlayConnectCtx::a_id, ConnectivitySuggestContext::csh, GNUNET_ATS_connectivity_suggest(), send_hello(), and RemoteOverlayConnectCtx::tcc.

Referenced by rocc_hello_sent_cb().

806 {
807  struct RemoteOverlayConnectCtx *rocc = cls;
808 
809  rocc->tcc.csh =
811  &rocc->a_id,
812  1);
813 }
struct GNUNET_PeerIdentity a_id
The peer identity of peer A.
struct ConnectivitySuggestContext tcc
The transport try connect context.
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.
Context information for remote overlay connect operations.
struct GNUNET_ATS_ConnectivitySuggestHandle * csh
The ATS handle for the connectivity suggestion.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_hello()

static void send_hello ( void *  cls)
static

Task to offer HELLO of peer 1 to peer 2 and try to make peer 2 to connect to peer 1.

Task to offer HELLO of peer 1 to peer 2.

Parameters
clsthe OverlayConnectContext

If peer2 is local it is offered using its TRANSPORT connection; if remote the HELLO is sent remotely by using send_hello_thru_rocc()

Parameters
clsthe OverlayConnectContext

Definition at line 911 of file gnunet-service-testbed_oc.c.

References ConnectivitySuggestContext::cfg, GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_free, GNUNET_i2s(), GNUNET_SCHEDULER_add_delayed(), GNUNET_strdup, GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_TRANSPORT_offer_hello(), OverlayConnectContext::hello, OverlayConnectContext::local, LOG_DEBUG, occ_hello_sent_cb(), OCC_TYPE_LOCAL, LocalPeer2Context::ohh, OverlayConnectContext::op_id, OverlayConnectContext::other_peer_identity, OverlayConnectContext::p2ctx, OverlayConnectContext::peer_identity, OverlayConnectContext::send_hello_task, send_hello_thru_rocc(), LocalPeer2Context::tcc, OverlayConnectContext::timeout_task, and OverlayConnectContext::type.

Referenced by occ_cache_get_handle_ats_rocc_cb(), p2_transport_connect(), and p2_transport_connect_cache_callback().

912 {
913  struct OverlayConnectContext *occ = cls;
914  struct LocalPeer2Context *lp2c;
915  char *other_peer_str;
916 
917  occ->send_hello_task = NULL;
918  GNUNET_assert (NULL != occ->timeout_task);
919  GNUNET_assert (NULL != occ->hello);
920  if (OCC_TYPE_LOCAL != occ->type)
921  {
922  send_hello_thru_rocc (occ);
923  return;
924  }
925  lp2c = &occ->p2ctx.local;
926  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
927  LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n",
928  occ->op_id,
929  GNUNET_i2s (&occ->peer_identity),
930  other_peer_str);
931  GNUNET_free (other_peer_str);
932  lp2c->ohh =
934  occ->hello,
936  occ);
937  if (NULL == lp2c->ohh)
938  {
939  GNUNET_break (0);
940  occ->send_hello_task =
943  100 +
946  &send_hello, occ);
947  }
948 }
uint64_t op_id
The id of the operation responsible for creating this context.
static void send_hello_thru_rocc(struct OverlayConnectContext *occ)
Sends the HELLO of peer1 to peer2's controller through remote overlay connect request.
Context data for operations on second peer in local overlay connection contexts.
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
The handle for offering the HELLO of the first peer to the second peer.
Context information for connecting 2 peers in overlay.
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_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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:1246
enum OverlayConnectContextType type
The type of this context information.
struct LocalPeer2Context local
Context information to be used if the second peer is local.
static void send_hello(void *cls)
Task to offer HELLO of peer 1 to peer 2 and try to make peer 2 to connect to peer 1...
struct GNUNET_MessageHeader * hello
HELLO of the first peer.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:439
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration of the peer from cache.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
This type is used if the overlay connection is local i.e.
struct GNUNET_SCHEDULER_Task * send_hello_task
The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to connect to peer 2...
struct GNUNET_PeerIdentity peer_identity
The peer identity of the first peer.
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
static void occ_hello_sent_cb(void *cls)
Task that is run when hello has been sent If tc->reason = GNUNET_SCHEDULER_REASON_TIMEOUT then sendin...
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.
#define LOG_DEBUG(msg)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_free(ptr)
Wrapper around free.
struct ConnectivitySuggestContext tcc
The transport ConnectivitySuggestContext.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ occ_hello_sent_cb()

static void occ_hello_sent_cb ( void *  cls)
static

Task that is run when hello has been sent If tc->reason = GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if GNUNET_SCHEDULER_REASON_READ_READY is succeeded.

Parameters
clsthe overlay connect context

Definition at line 834 of file gnunet-service-testbed_oc.c.

References ConnectivitySuggestContext::cgh_p2_ats, Peer::details, OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_free_non_null, GNUNET_i2s(), GST_connection_pool_get_handle(), GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY, GST_peer_list, Peer::local, OverlayConnectContext::local, occ_cache_get_handle_ats_occ_cb(), OCC_TYPE_LOCAL, LocalPeer2Context::ohh, OverlayConnectContext::op_id, OverlayConnectContext::other_peer_id, OverlayConnectContext::other_peer_identity, OverlayConnectContext::p2ctx, OverlayConnectContext::send_hello_task, LocalPeer2Context::tcc, OverlayConnectContext::timeout_task, and OverlayConnectContext::type.

Referenced by send_hello().

835 {
836  struct OverlayConnectContext *occ = cls;
837  struct LocalPeer2Context *lp2c;
838  struct Peer *peer2;
839 
841  GNUNET_assert (NULL != occ->timeout_task);
842  lp2c = &occ->p2ctx.local;
843  lp2c->ohh = NULL;
844 
845  GNUNET_assert (NULL == occ->send_hello_task);
846  GNUNET_free_non_null (occ->emsg);
847 
848  GNUNET_asprintf (&occ->emsg,
849  "0x%llx: Timeout while acquiring ATS of %s from cache",
850  occ->op_id,
852  GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
853  lp2c->tcc.cgh_p2_ats =
855  peer2->details.local.cfg,
858  occ, NULL, NULL, NULL);
859 }
uint64_t op_id
The id of the operation responsible for creating this context.
Context data for operations on second peer in local overlay connection contexts.
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
The handle for offering the HELLO of the first peer to the second peer.
static void occ_cache_get_handle_ats_occ_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed ATS handle set.
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct Peer ** GST_peer_list
A list of peers we know about.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
char * emsg
The error message we send if this overlay connect operation has timed out.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct Peer::@69::@70 local
enum OverlayConnectContextType type
The type of this context information.
struct LocalPeer2Context local
Context information to be used if the second peer is local.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
This type is used if the overlay connection is local i.e.
struct GNUNET_SCHEDULER_Task * send_hello_task
The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to connect to peer 2...
uint32_t other_peer_id
The id of the second peer which has to connect to the first peer.
union Peer::@69 details
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
Information about preferences and sessions we track per peer.
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GST_ConnectionPool_GetHandle * cgh_p2_ats
The GetCacheHandle for the peer2's ATS handle.
struct ConnectivitySuggestContext tcc
The transport ConnectivitySuggestContext.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_hello_thru_rocc()

static void send_hello_thru_rocc ( struct OverlayConnectContext occ)
static

Sends the HELLO of peer1 to peer2's controller through remote overlay connect request.

Parameters
occthe overlay connect context. Its type must be either OCC_TYPE_REMOTE_SLAVE or OCC_TYPE_REMOTE_LATERAL

Definition at line 870 of file gnunet-service-testbed_oc.c.

References GNUNET_assert, GNUNET_free, GNUNET_htonll(), GNUNET_i2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT, GNUNET_strdup, GNUNET_TESTBED_queue_message_(), OverlayConnectContext::hello, LOG_DEBUG, msg, OCC_TYPE_LOCAL, OverlayConnectContext::op_id, OverlayConnectContext::other_peer_id, OverlayConnectContext::other_peer_identity, RemotePeer2Context::p2c, OverlayConnectContext::p2ctx, OverlayConnectContext::peer_identity, OverlayConnectContext::remote, GNUNET_MessageHeader::size, and OverlayConnectContext::type.

Referenced by send_hello().

871 {
873  char *other_peer_str;
874  uint16_t msize;
875  uint16_t hello_size;
876 
878  GNUNET_assert (NULL != occ->hello);
879  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
880  LOG_DEBUG ("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote Overlay Request\n",
881  occ->op_id,
882  GNUNET_i2s (&occ->peer_identity),
883  ntohs (occ->hello->size),
884  other_peer_str);
885  GNUNET_free (other_peer_str);
886  hello_size = ntohs (occ->hello->size);
887  msize = sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hello_size;
888  msg = GNUNET_malloc (msize);
889  msg->header.type =
891  msg->header.size = htons (msize);
892  msg->peer = htonl (occ->other_peer_id);
893  msg->operation_id = GNUNET_htonll (occ->op_id);
894  msg->peer_identity = occ->peer_identity;
895  GNUNET_memcpy (msg->hello,
896  occ->hello,
897  hello_size);
899  &msg->header);
900 }
uint64_t op_id
The id of the operation responsible for creating this context.
Message sent from host controller of a peer(A) to the host controller of another peer(B) to request B...
Definition: testbed.h:431
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct RemotePeer2Context remote
Context information to be used if the second peer is remote.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_TESTBED_Controller * p2c
Controller of peer 2; If OCC_TYPE_REMOTE_LATERAL is the type of overlay connection then this can be N...
#define GNUNET_memcpy(dst, src, n)
#define GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT
Message to request a controller to make one of its peer to connect to another peer using the containe...
enum OverlayConnectContextType type
The type of this context information.
struct GNUNET_MessageHeader * hello
HELLO of the first peer.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
This type is used if the overlay connection is local i.e.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1315
uint32_t other_peer_id
The id of the second peer which has to connect to the first peer.
struct GNUNET_PeerIdentity peer_identity
The peer identity of the first peer.
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
#define LOG_DEBUG(msg)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ p2_transport_connect_cache_callback()

static void p2_transport_connect_cache_callback ( void *  cls,
struct GNUNET_CORE_Handle ch,
struct GNUNET_TRANSPORT_CoreHandle th,
struct GNUNET_ATS_ConnectivityHandle ac,
const struct GNUNET_PeerIdentity ignore_,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Callback from cache with needed handles set.

Parameters
clsthe closure passed to GST_cache_get_handle_transport()
chthe handle to CORE. Can be NULL if it is not requested
ththe handle to TRANSPORT. Can be NULL if it is not requested
acthe handle to ATS. Can be NULL if it is not requested
ignore_peer identity which is ignored in this callback
cfgconfiguration of the peer

Definition at line 962 of file gnunet-service-testbed_oc.c.

References ConnectivitySuggestContext::cfg, OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_i2s(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), OverlayConnectContext::local, OCC_TYPE_LOCAL, OverlayConnectContext::op_id, OverlayConnectContext::other_peer_identity, OverlayConnectContext::p2ctx, send_hello(), OverlayConnectContext::send_hello_task, LocalPeer2Context::tcc, ConnectivitySuggestContext::th_, timeout_overlay_connect(), OverlayConnectContext::timeout_task, and OverlayConnectContext::type.

Referenced by p2_transport_connect().

968 {
969  struct OverlayConnectContext *occ = cls;
970 
972  if (NULL == th)
973  {
974  GNUNET_asprintf (&occ->emsg,
975  "0x%llx: Cannot connect to TRANSPORT of %s",
976  occ->op_id,
979  occ->timeout_task =
981  return;
982  }
983  occ->p2ctx.local.tcc.th_ = th;
984  occ->p2ctx.local.tcc.cfg = cfg;
985  GNUNET_asprintf (&occ->emsg,
986  "0x%llx: Timeout while offering HELLO to %s",
987  occ->op_id,
990 }
uint64_t op_id
The id of the operation responsible for creating this context.
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
char * emsg
The error message we send if this overlay connect operation has timed out.
static void timeout_overlay_connect(void *cls)
Task which will be run when overlay connect request has been timed out.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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.
Definition: scheduler.c:1273
enum OverlayConnectContextType type
The type of this context information.
struct LocalPeer2Context local
Context information to be used if the second peer is local.
static void send_hello(void *cls)
Task to offer HELLO of peer 1 to peer 2 and try to make peer 2 to connect to peer 1...
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration of the peer from cache.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
This type is used if the overlay connection is local i.e.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
struct GNUNET_SCHEDULER_Task * send_hello_task
The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to connect to peer 2...
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
struct GNUNET_TRANSPORT_CoreHandle * th_
The transport handle obtained from cache.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
struct ConnectivitySuggestContext tcc
The transport ConnectivitySuggestContext.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ p2_transport_connect()

static void p2_transport_connect ( struct OverlayConnectContext occ)
static

Connects to the transport of the other peer if it is a local peer and schedules the send hello task.

Parameters
occthe overlay connect context

Definition at line 1000 of file gnunet-service-testbed_oc.c.

References OverlayConnectContext::cgh_p1th, ConnectivitySuggestContext::cgh_p2_th, Peer::details, OverlayConnectContext::emsg, OverlayConnectContext::ghh, GNUNET_asprintf(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_add_now(), GST_connection_pool_get_handle(), GST_CONNECTIONPOOL_SERVICE_TRANSPORT, GST_peer_list, OverlayConnectContext::hello, Peer::local, OverlayConnectContext::local, OCC_TYPE_LOCAL, OverlayConnectContext::op_id, OverlayConnectContext::other_peer_id, OverlayConnectContext::other_peer_identity, OverlayConnectContext::p1th_, p2_transport_connect_cache_callback(), OverlayConnectContext::p2ctx, send_hello(), OverlayConnectContext::send_hello_task, LocalPeer2Context::tcc, and OverlayConnectContext::type.

Referenced by hello_update_cb(), and occ_cache_get_handle_core_cb().

1001 {
1002  struct Peer *peer2;
1003 
1004  /* HUH? Why to *obtain* HELLO? Seems we use this to *SEND* the
1005  HELLO! */
1007  "Connecting to transport of peer %s to obtain HELLO\n",
1009  GNUNET_assert (NULL == occ->emsg);
1010  GNUNET_assert (NULL != occ->hello);
1011  GNUNET_assert (NULL == occ->ghh);
1012  GNUNET_assert (NULL == occ->p1th_);
1013  GNUNET_assert (NULL == occ->cgh_p1th);
1014  if (OCC_TYPE_LOCAL == occ->type)
1015  {
1016  GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
1017  occ->p2ctx.local.tcc.cgh_p2_th =
1019  peer2->details.local.cfg,
1022  occ, NULL, NULL, NULL);
1023  return;
1024  }
1025  GNUNET_asprintf (&occ->emsg,
1026  "0x%llx: Timeout while offering HELLO to %s",
1027  occ->op_id,
1030 }
uint64_t op_id
The id of the operation responsible for creating this context.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct Peer ** GST_peer_list
A list of peers we know about.
struct GST_ConnectionPool_GetHandle * cgh_p1th
The GST_ConnectionPool_GetHandle for the peer1's transport handle.
char * emsg
The error message we send if this overlay connect operation has timed out.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct Peer::@69::@70 local
struct GNUNET_TRANSPORT_CoreHandle * p1th_
Transport handle of the first peer obtained from cache to get its HELLO.
struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Get GetHelloHandle to acquire a HELLO of the first peer.
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.
Definition: scheduler.c:1273
enum OverlayConnectContextType type
The type of this context information.
struct LocalPeer2Context local
Context information to be used if the second peer is local.
static void send_hello(void *cls)
Task to offer HELLO of peer 1 to peer 2 and try to make peer 2 to connect to peer 1...
struct GNUNET_MessageHeader * hello
HELLO of the first peer.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
This type is used if the overlay connection is local i.e.
static void p2_transport_connect_cache_callback(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *ignore_, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed handles set.
struct GNUNET_SCHEDULER_Task * send_hello_task
The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to connect to peer 2...
uint32_t other_peer_id
The id of the second peer which has to connect to the first peer.
union Peer::@69 details
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
Information about preferences and sessions we track per peer.
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
#define GNUNET_log(kind,...)
struct GST_ConnectionPool_GetHandle * cgh_p2_th
The GetCacheHandle for the peer2's transport handle (used to offer the HELLO to the peer)...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct ConnectivitySuggestContext tcc
The transport ConnectivitySuggestContext.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_address()

static int test_address ( void *  cls,
const struct GNUNET_HELLO_Address address,
struct GNUNET_TIME_Absolute  expiration 
)
static

Test for checking whether HELLO message is empty.

Parameters
clsempty flag to set
addressthe HELLO
expirationexpiration of the HELLO
Returns
GNUNET_OK

Definition at line 1042 of file gnunet-service-testbed_oc.c.

References GNUNET_NO, and GNUNET_OK.

Referenced by GNUNET_ATS_solver_generate_property_start(), and hello_update_cb().

1045 {
1046  int *empty = cls;
1047 
1048  *empty = GNUNET_NO;
1049  return GNUNET_OK;
1050 }
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Here is the caller graph for this function:

◆ hello_update_cb()

static void hello_update_cb ( void *  cls,
const struct GNUNET_MessageHeader hello 
)
static

Function called whenever there is an update to the HELLO of peers in the OverlayConnectClosure.

If we have a valid HELLO, we connect to the peer 2's transport and offer peer 1's HELLO and ask peer 2 to connect to peer 1

Parameters
clsclosure
helloour updated HELLO

Definition at line 1062 of file gnunet-service-testbed_oc.c.

References OverlayConnectContext::cgh_p1th, OverlayConnectContext::emsg, OverlayConnectContext::ghh, GNUNET_free_non_null, GNUNET_HELLO_iterate_addresses(), GNUNET_i2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_TRANSPORT_hello_get_cancel(), GNUNET_YES, GST_cache_add_hello(), GST_connection_pool_get_handle_done(), OverlayConnectContext::hello, Peer::id, LOG_DEBUG, OverlayConnectContext::op_id, OverlayConnectContext::p1th_, p2_transport_connect(), OverlayConnectContext::peer, OverlayConnectContext::peer_identity, GNUNET_MessageHeader::size, and test_address().

Referenced by p1_transport_connect_cache_callback().

1064 {
1065  struct OverlayConnectContext *occ = cls;
1066  int empty;
1067  uint16_t msize;
1068 
1069  msize = ntohs (hello->size);
1070  empty = GNUNET_YES;
1071  (void) GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *)
1072  hello, GNUNET_NO,
1073  &test_address,
1074  &empty);
1075  if (GNUNET_YES == empty)
1076  {
1077  LOG_DEBUG ("0x%llx: HELLO of %s is empty\n",
1078  occ->op_id,
1079  GNUNET_i2s (&occ->peer_identity));
1080  return;
1081  }
1082  LOG_DEBUG ("0x%llx: Received HELLO of %s\n",
1083  occ->op_id,
1084  GNUNET_i2s (&occ->peer_identity));
1085  occ->hello = GNUNET_malloc (msize);
1086  GST_cache_add_hello (occ->peer->id, hello);
1087  GNUNET_memcpy (occ->hello, hello, msize);
1089  occ->ghh = NULL;
1091  occ->cgh_p1th = NULL;
1092  occ->p1th_ = NULL;
1093  GNUNET_free_non_null (occ->emsg);
1094  occ->emsg = NULL;
1095  p2_transport_connect (occ);
1096 }
uint64_t op_id
The id of the operation responsible for creating this context.
A HELLO message is used to exchange information about transports with other peers.
static void p2_transport_connect(struct OverlayConnectContext *occ)
Connects to the transport of the other peer if it is a local peer and schedules the send hello task...
Context information for connecting 2 peers in overlay.
uint32_t id
Our local reference id for this peer.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GST_ConnectionPool_GetHandle * cgh_p1th
The GST_ConnectionPool_GetHandle for the peer1's transport handle.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
char * emsg
The error message we send if this overlay connect operation has timed out.
#define GNUNET_memcpy(dst, src, n)
struct GNUNET_TRANSPORT_CoreHandle * p1th_
Transport handle of the first peer obtained from cache to get its HELLO.
struct Peer * peer
the first peer which is to expect an overlay connection from the second peer.
struct GNUNET_HELLO_Message * GNUNET_HELLO_iterate_addresses(const struct GNUNET_HELLO_Message *msg, int return_modified, GNUNET_HELLO_AddressIterator it, void *it_cls)
Iterate over all of the addresses in the HELLO.
Definition: hello.c:254
struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Get GetHelloHandle to acquire a HELLO of the first peer.
struct GNUNET_MessageHeader * hello
HELLO of the first peer.
struct GNUNET_PeerIdentity peer_identity
The peer identity of the first peer.
static int test_address(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Test for checking whether HELLO message is empty.
#define GNUNET_YES
Definition: gnunet_common.h:80
#define LOG_DEBUG(msg)
void GST_connection_pool_get_handle_done(struct GST_ConnectionPool_GetHandle *gh)
Relinquish a GST_ConnectionPool_GetHandle object.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_TRANSPORT_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
Stop receiving updates about changes to our HELLO message.
#define GNUNET_malloc(size)
Wrapper around malloc.
void GST_cache_add_hello(const unsigned int peer_id, const struct GNUNET_MessageHeader *hello)
Caches the HELLO of the given peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ p1_transport_connect_cache_callback()

static void p1_transport_connect_cache_callback ( void *  cls,
struct GNUNET_CORE_Handle ch,
struct GNUNET_TRANSPORT_CoreHandle th,
struct GNUNET_ATS_ConnectivityHandle ac,
const struct GNUNET_PeerIdentity ignore_,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Callback from cache with needed handles set.

Parameters
clsthe closure passed to GST_cache_get_handle_transport()
chthe handle to CORE. Can be NULL if it is not requested
ththe handle to TRANSPORT. Can be NULL if it is not requested
acthe handle to ATS. Can be NULL if it is not requested
ignore_peer identity which is ignored in this callback

Definition at line 1109 of file gnunet-service-testbed_oc.c.

References OverlayConnectContext::cgh_p1th, OverlayConnectContext::emsg, OverlayConnectContext::ghh, GNUNET_asprintf(), GNUNET_assert, GNUNET_free_non_null, GNUNET_i2s(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_AC_ANY, GNUNET_TRANSPORT_hello_get(), hello_update_cb(), OverlayConnectContext::op_id, OverlayConnectContext::p1th_, OverlayConnectContext::peer_identity, timeout_overlay_connect(), and OverlayConnectContext::timeout_task.

Referenced by occ_cache_get_handle_core_cb().

1115 {
1116  struct OverlayConnectContext *occ = cls;
1117 
1118  GNUNET_free_non_null (occ->emsg);
1119  occ->emsg = NULL;
1120  if (NULL == th)
1121  {
1122  GNUNET_asprintf (&occ->emsg,
1123  "0x%llx: Cannot connect to TRANSPORT of %s",
1124  occ->op_id,
1125  GNUNET_i2s (&occ->peer_identity));
1127  occ->timeout_task =
1129  return;
1130  }
1131  GNUNET_assert (NULL == occ->p1th_);
1132  GNUNET_assert (NULL != occ->cgh_p1th);
1133  occ->p1th_ = th;
1134  GNUNET_asprintf (&occ->emsg,
1135  "0x%llx: Timeout while acquiring HELLO of peer %s",
1136  occ->op_id,
1137  GNUNET_i2s (&occ->peer_identity));
1138  occ->ghh = GNUNET_TRANSPORT_hello_get (cfg,
1140  &hello_update_cb,
1141  occ);
1142 }
uint64_t op_id
The id of the operation responsible for creating this context.
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void hello_update_cb(void *cls, const struct GNUNET_MessageHeader *hello)
Function called whenever there is an update to the HELLO of peers in the OverlayConnectClosure.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GST_ConnectionPool_GetHandle * cgh_p1th
The GST_ConnectionPool_GetHandle for the peer1's transport handle.
char * emsg
The error message we send if this overlay connect operation has timed out.
static void timeout_overlay_connect(void *cls)
Task which will be run when overlay connect request has been timed out.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct GNUNET_TRANSPORT_CoreHandle * p1th_
Transport handle of the first peer obtained from cache to get its HELLO.
struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Get GetHelloHandle to acquire a HELLO of the first peer.
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.
Definition: scheduler.c:1273
struct GNUNET_PeerIdentity peer_identity
The peer identity of the first peer.
struct GNUNET_TRANSPORT_HelloGetHandle * GNUNET_TRANSPORT_hello_get(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_TRANSPORT_AddressClass ac, GNUNET_TRANSPORT_HelloUpdateCallback rec, void *rec_cls)
Obtain updates on changes to the HELLO message for this peer.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ occ_cache_get_handle_core_cb()

static void occ_cache_get_handle_core_cb ( void *  cls,
struct GNUNET_CORE_Handle ch,
struct GNUNET_TRANSPORT_CoreHandle th,
struct GNUNET_ATS_ConnectivityHandle ac,
const struct GNUNET_PeerIdentity my_identity,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Callback from cache with needed CORE handle set.

Parameters
clsthe closure passed to GST_cache_get_handle_transport()
chthe handle to CORE. Can be NULL if it is not requested
ththe handle to TRANSPORT. Can be NULL if it is not requested
acthe handle to ATS. Can be NULL if it is not requested
my_identitythe identity of our peer

Definition at line 1155 of file gnunet-service-testbed_oc.c.

References OverlayConnectContext::cgh_p1th, OverlayConnectContext::cleanup_task, Peer::details, do_cleanup_occ(), OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_copy_message(), GNUNET_CORE_get_mq(), GNUNET_free_non_null, GNUNET_i2s(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GST_cache_lookup_hello(), GST_connection_pool_get_handle(), GST_CONNECTIONPOOL_SERVICE_TRANSPORT, OverlayConnectContext::hello, Peer::id, Peer::local, LOG_DEBUG, my_identity, OverlayConnectContext::op_id, OverlayConnectContext::other_peer_identity, p1_transport_connect_cache_callback(), p2_transport_connect(), OverlayConnectContext::peer, OverlayConnectContext::peer_identity, send_overlay_connect_success_msg(), timeout_overlay_connect(), and OverlayConnectContext::timeout_task.

Referenced by handle_overlay_connect(), and overlay_connect_get_config().

1161 {
1162  struct OverlayConnectContext *occ = cls;
1163  const struct GNUNET_MessageHeader *hello;
1164 
1165  GNUNET_assert (NULL != occ->timeout_task);
1166  GNUNET_free_non_null (occ->emsg);
1167  if ((NULL == ch) || (NULL == my_identity))
1168  {
1169  GNUNET_asprintf (&occ->emsg,
1170  "0x%llx: Failed to connect to CORE of peer with "
1171  "id: %u",
1172  occ->op_id,
1173  occ->peer->id);
1175  occ->timeout_task =
1177  return;
1178  }
1179  occ->emsg = NULL;
1180  if (NULL !=
1181  GNUNET_CORE_get_mq (ch,
1182  &occ->other_peer_identity))
1183  {
1184  LOG_DEBUG ("0x%llx: Target peer already connected\n",
1185  occ->op_id);
1187  occ->timeout_task = NULL;
1190  return;
1191  }
1192  occ->peer_identity = *my_identity;
1193  LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n",
1194  occ->op_id,
1195  GNUNET_i2s (&occ->peer_identity));
1196  /* Lookup for HELLO in hello cache */
1197  if (NULL != (hello = GST_cache_lookup_hello (occ->peer->id)))
1198  {
1199  LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n",
1200  occ->op_id,
1201  GNUNET_i2s (&occ->peer_identity));
1202  occ->hello = GNUNET_copy_message (hello);
1203  p2_transport_connect (occ);
1204  return;
1205  }
1206  GNUNET_asprintf (&occ->emsg,
1207  "0x%llx: Timeout while acquiring TRANSPORT of %s from cache",
1208  occ->op_id,
1209  GNUNET_i2s (&occ->peer_identity));
1210  occ->cgh_p1th =
1212  occ->peer->details.local.cfg,
1215  occ,
1216  NULL, NULL, NULL);
1217 }
uint64_t op_id
The id of the operation responsible for creating this context.
static void p2_transport_connect(struct OverlayConnectContext *occ)
Connects to the transport of the other peer if it is a local peer and schedules the send hello task...
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Our local reference id for this peer.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
struct GST_ConnectionPool_GetHandle * cgh_p1th
The GST_ConnectionPool_GetHandle for the peer1's transport handle.
char * emsg
The error message we send if this overlay connect operation has timed out.
static void timeout_overlay_connect(void *cls)
Task which will be run when overlay connect request has been timed out.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct Peer::@69::@70 local
struct Peer * peer
the first peer which is to expect an overlay connection from the second peer.
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.
Definition: scheduler.c:1273
struct GNUNET_MessageHeader * hello
HELLO of the first peer.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
const struct GNUNET_MessageHeader * GST_cache_lookup_hello(const unsigned int peer_id)
Looks up in the hello cache and returns the HELLO of the given peer.
static void p1_transport_connect_cache_callback(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *ignore_, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed handles set.
static void send_overlay_connect_success_msg(struct OverlayConnectContext *occ)
FIXME.
struct GNUNET_MQ_Handle * GNUNET_CORE_get_mq(const struct GNUNET_CORE_Handle *h, const struct GNUNET_PeerIdentity *pid)
Obtain the message queue for a connected peer.
Definition: core_api.c:763
struct GNUNET_PeerIdentity peer_identity
The peer identity of the first peer.
union Peer::@69 details
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
struct GNUNET_SCHEDULER_Task * cleanup_task
The id of the cleanup task.
Header for all communications.
#define LOG_DEBUG(msg)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static void do_cleanup_occ(void *cls)
Task for cleaing up overlay connect context structure.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ overlay_connect_get_config()

static void overlay_connect_get_config ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Callback to be called when forwarded get peer config operation as part of overlay connect is successfull.

Connection to Peer 1's core is made and is checked for new connection from peer 2

Parameters
clsForwardedOperationContext
msgthe peer create success message

Definition at line 1229 of file gnunet-service-testbed_oc.c.

References OverlayConnectContext::cgh_ch, Peer::details, OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_free_non_null, GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GST_connection_pool_get_handle(), GST_CONNECTIONPOOL_SERVICE_CORE, Peer::id, Peer::local, occ_cache_get_handle_core_cb(), OCC_TYPE_LOCAL, OverlayConnectContext::op_id, RemotePeer2Context::opc, OverlayConnectContext::other_peer_identity, overlay_connect_notify(), OverlayConnectContext::p2ctx, OverlayConnectContext::peer, GNUNET_TESTBED_PeerConfigurationInformationMessage::peer_identity, OverlayConnectContext::remote, timeout_overlay_connect(), OverlayConnectContext::timeout_task, OverlayConnectContext::type, and GNUNET_MessageHeader::type.

Referenced by p2_controller_connect_cb().

1231 {
1232  struct OverlayConnectContext *occ = cls;
1233  struct RemotePeer2Context *rp2c;
1235 
1236  GNUNET_assert (OCC_TYPE_LOCAL != occ->type);
1237  rp2c = &occ->p2ctx.remote;
1238  rp2c->opc = NULL;
1239  GNUNET_assert (NULL != occ->timeout_task);
1241  {
1243  occ->timeout_task =
1245  }
1246  cmsg =
1248  occ->other_peer_identity = cmsg->peer_identity;
1249  GNUNET_free_non_null (occ->emsg);
1250  GNUNET_asprintf (&occ->emsg,
1251  "0x%llx: Timeout while connecting to CORE of peer with "
1252  "id: %u",
1253  occ->op_id,
1254  occ->peer->id);
1255  occ->cgh_ch =
1257  occ->peer->details.local.cfg,
1260  occ,
1261  &occ->other_peer_identity,
1263  occ);
1264  return;
1265 }
static void occ_cache_get_handle_core_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed CORE handle set.
uint64_t op_id
The id of the operation responsible for creating this context.
struct GST_ConnectionPool_GetHandle * cgh_ch
The GST_ConnectionPool_GetHandle for registering callback to notify CORE level peer connects and to g...
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Our local reference id for this peer.
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:639
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Context data for operations on second peer in remote overlay connection contexts. ...
struct RemotePeer2Context remote
Context information to be used if the second peer is remote.
char * emsg
The error message we send if this overlay connect operation has timed out.
static void timeout_overlay_connect(void *cls)
Task which will be run when overlay connect request has been timed out.
static void overlay_connect_notify(void *cls, const struct GNUNET_PeerIdentity *new_peer)
Function called to notify transport users that another peer connected to us.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct Peer::@69::@70 local
struct Peer * peer
the first peer which is to expect an overlay connection from the second peer.
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.
Definition: scheduler.c:1273
enum OverlayConnectContextType type
The type of this context information.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer's information.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
struct GNUNET_PeerIdentity peer_identity
Identity of the peer.
Definition: testbed.h:660
This type is used if the overlay connection is local i.e.
union Peer::@69 details
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
struct OperationContext * opc
Operation context for the suboperation we start to get the identity of the second peer...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ host_registration_comp()

static void host_registration_comp ( void *  cls,
const char *  emsg 
)
static

Callback which will be called after a host registration succeeded or failed.

Parameters
clsthe RegisteredHostContext
emsgthe error message; NULL if host registration is successful

Definition at line 1275 of file gnunet-service-testbed_oc.c.

References GST_process_next_focc(), RegisteredHostContext::RHC_DONE, and RegisteredHostContext::state.

Referenced by register_host().

1276 {
1277  struct RegisteredHostContext *rhc = cls;
1278 
1279  rhc->state = RHC_DONE;
1280  GST_process_next_focc (rhc);
1281 }
This context information will be created for each host that is registered at slave controllers during...
enum RegisteredHostContext::RHCState state
void GST_process_next_focc(struct RegisteredHostContext *rhc)
Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext.
State where we attempt to do the overlay connection again.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reghost_match_iterator()

static int reghost_match_iterator ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Iterator to match a registered host context.

Parameters
clspointer 2 pointer of RegisteredHostContext
keycurrent key code
valuevalue in the hash map
Returns
GNUNET_YES if we should continue to iterate, GNUNET_NO if not.

Definition at line 1295 of file gnunet-service-testbed_oc.c.

References GNUNET_free, GNUNET_NO, GNUNET_YES, RegisteredHostContext::host, RegisteredHostContext::reg_host, and value.

Referenced by register_host().

1298 {
1299  struct RegisteredHostContext **rh = cls;
1300  struct RegisteredHostContext *rh_val = value;
1301 
1302  if ((rh_val->host == (*rh)->host) && (rh_val->reg_host == (*rh)->reg_host))
1303  {
1304  GNUNET_free (*rh);
1305  *rh = rh_val;
1306  return GNUNET_NO;
1307  }
1308  return GNUNET_YES;
1309 }
This context information will be created for each host that is registered at slave controllers during...
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_TESTBED_Host * host
The host of the controller which has to connect to the above rhost.
static char * value
Value of the record to add/remove.
struct GNUNET_TESTBED_Host * reg_host
The host which is being registered.
#define GNUNET_YES
Definition: gnunet_common.h:80
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ hash_hosts()

static struct GNUNET_HashCode hash_hosts ( struct GNUNET_TESTBED_Host reg_host,
struct GNUNET_TESTBED_Host host 
)
static

Function to generate the hashcode corresponding to a RegisteredHostContext.

Parameters
reg_hostthe host which is being registered in RegisteredHostContext
hostthe host of the controller which has to connect to the above rhost
Returns
the hashcode

Definition at line 1320 of file gnunet-service-testbed_oc.c.

References GNUNET_CRYPTO_hash(), GNUNET_TESTBED_host_get_id_(), and host.

Referenced by register_host().

1322 {
1323  struct GNUNET_HashCode hash;
1324  uint32_t host_ids[2];
1325 
1326  host_ids[0] = GNUNET_TESTBED_host_get_id_ (reg_host);
1327  host_ids[1] = GNUNET_TESTBED_host_get_id_ (host);
1328  GNUNET_CRYPTO_hash (host_ids, sizeof (host_ids), &hash);
1329  return hash;
1330 }
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host's unique global ID.
A 512-bit hashcode.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_host()

static struct RegisteredHostContext* register_host ( struct Slave slave,
struct GNUNET_TESTBED_Host host 
)
static

Checks if the given host is registered at the given slave.

Parameters
slavethe slave where registration has to be checked. The check is actually done through a locally maintained hashmap. No communication with the slave is involved.
hostthe host to register
Returns
If the given host is not registered already or the registration is pending, it returns the registration context. Any overlay connects to be forwarded should be queued in the context so that they can be executed when the registration is completed. If the given host is already registered, NULL is returned.

Definition at line 1347 of file gnunet-service-testbed_oc.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_new, GNUNET_NO, GNUNET_SYSERR, GST_host_list, GST_queue_host_registration(), hash_hosts(), host, RegisteredHostContext::host, Slave::host_id, host_registration_comp(), RegisteredHostContext::reg_host, Slave::reghost_map, reghost_match_iterator(), RegisteredHostContext::RHC_DONE, RegisteredHostContext::RHC_INIT, and RegisteredHostContext::state.

Referenced by forward_overlay_connect().

1349 {
1350  struct GNUNET_HashCode hash;
1351  struct RegisteredHostContext *rhc;
1352 
1353  rhc = GNUNET_new (struct RegisteredHostContext);
1354  rhc->reg_host = host;
1355  rhc->host = GST_host_list[slave->host_id];
1356  GNUNET_assert (NULL != rhc->reg_host);
1357  GNUNET_assert (NULL != rhc->host);
1358  rhc->state = RHC_INIT;
1359  hash = hash_hosts (rhc->reg_host, rhc->host);
1360  if ((GNUNET_NO ==
1362  &hash)) ||
1363  (GNUNET_SYSERR !=
1365  &hash,
1367  &rhc)))
1368  {
1369  /* create and add a new registerd host context */
1370  /* add the focc to its queue */
1372  &hash,
1373  rhc,
1377  rhc,
1378  rhc->reg_host);
1379  }
1380  else
1381  {
1382  /* rhc is now set to the existing one from the hash map by
1383  * reghost_match_iterator() */
1384  /* if queue is empty then ignore creating focc and proceed with normal
1385  * forwarding */
1386  if (RHC_DONE == rhc->state)
1387  return NULL;
1388  }
1389  return rhc;
1390 }
struct GNUNET_CONTAINER_MultiHashMap * reghost_map
Hashmap to hold Registered host contexts.
This context information will be created for each host that is registered at slave controllers during...
static struct GNUNET_HashCode hash_hosts(struct GNUNET_TESTBED_Host *reg_host, struct GNUNET_TESTBED_Host *host)
Function to generate the hashcode corresponding to a RegisteredHostContext.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GST_queue_host_registration(struct Slave *slave, GNUNET_TESTBED_HostRegistrationCompletion cb, void *cb_cls, struct GNUNET_TESTBED_Host *host)
Adds a host registration's request to a slave's registration queue.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
struct GNUNET_TESTBED_Host * host
The host of the controller which has to connect to the above rhost.
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
A 512-bit hashcode.
enum RegisteredHostContext::RHCState state
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
GUID host
struct GNUNET_TESTBED_Host * reg_host
The host which is being registered.
int 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.
static int reghost_match_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator to match a registered host context.
Allow multiple values with the same key.
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.
uint32_t host_id
The id of the host this controller is running on.
State where we attempt to do the overlay connection again.
static void host_registration_comp(void *cls, const char *emsg)
Callback which will be called after a host registration succeeded or failed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ forward_overlay_connect()

static void forward_overlay_connect ( const struct GNUNET_TESTBED_OverlayConnectMessage msg,
struct GNUNET_SERVICE_Client client 
)
static

Forwards the overlay connect request to a slave controller.

Before forwarding, any hosts which are needed to be known by the slave controller to execute the overlay connect request are registered at slave.

Parameters
msgthe overlay connect request message to be forwarded
clientthe client to which the status of the forwarded request has to be notified

Definition at line 1403 of file gnunet-service-testbed_oc.c.

References ForwardedOperationContext::client, ForwardedOverlayConnectContext::client, Route::dest, Peer::details, RegisteredHostContext::focc_dll_head, RegisteredHostContext::focc_dll_tail, fopcq_head, fopcq_tail, GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_copy_message(), GNUNET_new, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_YES, GST_find_dest_route(), GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_host_list, GST_peer_list, GST_timeout, GNUNET_TESTBED_OverlayConnectMessage::header, Peer::is_remote, LOG_DEBUG, OP_OVERLAY_CONNECT, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, ForwardedOverlayConnectContext::operation_id, GNUNET_TESTBED_OverlayConnectMessage::operation_id, ForwardedOverlayConnectContext::orig_msg, peer, ForwardedOverlayConnectContext::peer1, GNUNET_TESTBED_OverlayConnectMessage::peer1, ForwardedOverlayConnectContext::peer2, GNUNET_TESTBED_OverlayConnectMessage::peer2, ForwardedOverlayConnectContext::peer2_host_id, GNUNET_TESTBED_OverlayConnectMessage::peer2_host_id, register_host(), Peer::remote, ForwardedOverlayConnectContext::rhc, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, VALID_HOST_ID, and VALID_PEER_ID.

Referenced by handle_overlay_connect().

1405 {
1406  struct ForwardedOperationContext *fopc;
1407  struct Route *route_to_peer2_host;
1408  struct Route *route_to_peer1_host;
1409  struct Peer *peer;
1410  struct RegisteredHostContext *rhc;
1411  struct ForwardedOverlayConnectContext *focc;
1412  uint64_t op_id;
1413  uint32_t peer2_host_id;
1414  uint32_t p1;
1415  uint32_t p2;
1416 
1417  p1 = ntohl (msg->peer1);
1418  p2 = ntohl (msg->peer2);
1419  op_id = GNUNET_ntohll (msg->operation_id);
1420  peer2_host_id = ntohl (msg->peer2_host_id);
1422  GNUNET_assert (VALID_HOST_ID (peer2_host_id));
1423  peer = GST_peer_list[p1];
1424  GNUNET_assert (GNUNET_YES == peer->is_remote);
1425  LOG_DEBUG ("0x%llx: Forwarding overlay connect\n", op_id);
1426  route_to_peer2_host = GST_find_dest_route (peer2_host_id);
1427  route_to_peer1_host = GST_find_dest_route
1428  (peer->details.remote.remote_host_id);
1429  GNUNET_assert (NULL != route_to_peer1_host);
1430  if ((NULL != route_to_peer2_host) &&
1431  (route_to_peer1_host->dest == route_to_peer2_host->dest))
1432  goto forward;
1433  /* Peer2 is either with us OR peer1 and peer2 can be reached through
1434  different subtrees OR peer2 is on a subtree unknown to us */
1435  if (NULL != (rhc = register_host (peer->details.remote.slave,
1436  GST_host_list[peer2_host_id])))
1437  {
1438  LOG_DEBUG ("Queueing forwarding FOCC for connecting peers %u and %u\n", p1, p2);
1440  focc->rhc = rhc;
1441  focc->peer1 = p1;
1442  focc->peer2 = p2;
1443  focc->peer2_host_id = peer2_host_id;
1444  focc->orig_msg = GNUNET_copy_message (&msg->header);
1445  focc->operation_id = op_id;
1446  focc->client = client;
1448  rhc->focc_dll_tail,
1449  focc);
1450  return;
1451  }
1452 
1453  forward:
1454  LOG_DEBUG ("Forwarding without FOCC for connecting peers %u and %u\n", p1, p2);
1455  fopc = GNUNET_new (struct ForwardedOperationContext);
1456  fopc->client = client;
1457  fopc->operation_id = op_id;
1458  fopc->type = OP_OVERLAY_CONNECT;
1459  fopc->opc =
1461  slave->controller, op_id,
1462  &msg->header,
1464  fopc);
1465  fopc->timeout_task =
1468  fopc);
1470  fopcq_tail,
1471  fopc);
1472 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
This context information will be created for each host that is registered at slave controllers during...
int is_remote
Is this peer locally created?
struct GNUNET_MessageHeader * orig_msg
A copy of the original overlay connect message.
struct Peer::@69::@71 remote
struct GNUNET_SERVICE_Client * client
The client handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct OperationContext * opc
The generated operation context.
struct ForwardedOverlayConnectContext * focc_dll_tail
Tail of the ForwardedOverlayConnectContext DLL.
struct Peer ** GST_peer_list
A list of peers we know about.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:412
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GST_forwarded_operation_reply_relay(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to relay the reply msg of a forwarded operation back to the client.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
uint32_t peer2
The id of peer 2.
uint32_t peer2
Unique ID for the second peer.
Definition: testbed.h:417
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:1246
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
uint64_t operation_id
The id of the operation which created this context information.
uint32_t peer1
Unique ID for the first peer.
Definition: testbed.h:407
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
enum OperationType type
The type of the operation which is forwarded.
Context information to used during operations which forward the overlay connect message.
uint32_t peer2_host_id
The ID of the host which runs peer2.
Definition: testbed.h:422
A routing entry.
struct Route * GST_find_dest_route(uint32_t host_id)
Finds the route with directly connected host as destination through which the destination host can be...
static struct RegisteredHostContext * register_host(struct Slave *slave, struct GNUNET_TESTBED_Host *host)
Checks if the given host is registered at the given slave.
uint32_t peer2_host_id
Id of the host where peer2 is running.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Overlay connection operation.
Definition: testbed_api.h:79
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct OperationContext * GNUNET_TESTBED_forward_operation_msg_(struct GNUNET_TESTBED_Controller *controller, uint64_t operation_id, const struct GNUNET_MessageHeader *msg, GNUNET_MQ_MessageCallback cc, void *cc_cls)
Sends the given message as an operation.
Definition: testbed_api.c:1349
#define VALID_HOST_ID(id)
Condition to check if host id is valid.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT.
Definition: testbed.h:402
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
union Peer::@69 details
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct RegisteredHostContext * rhc
Which host does this FOCC belong to?
uint64_t operation_id
The id of the operation that has been forwarded.
#define GNUNET_YES
Definition: gnunet_common.h:80
#define LOG_DEBUG(msg)
Context information for operations forwarded to subcontrollers.
uint32_t dest
destination host
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ p2_controller_connect_cb()

static void p2_controller_connect_cb ( void *  cls,
struct GNUNET_TESTBED_Controller c 
)
static

Callback called when a connection to the controller of peer2 has been established.

Parameters
clsthe overlay connect contexts
chandle to the controller connection

Definition at line 1483 of file gnunet-service-testbed_oc.c.

References OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_free_non_null, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION, GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTBED_PeerGetConfigurationMessage::header, RemotePeer2Context::ncn, OCC_TYPE_LOCAL, OverlayConnectContext::op_id, RemotePeer2Context::opc, GNUNET_TESTBED_PeerGetConfigurationMessage::operation_id, OverlayConnectContext::other_peer_id, overlay_connect_get_config(), RemotePeer2Context::p2c, OverlayConnectContext::p2ctx, GNUNET_TESTBED_PeerGetConfigurationMessage::peer_id, OverlayConnectContext::remote, GNUNET_MessageHeader::size, OverlayConnectContext::type, and GNUNET_MessageHeader::type.

Referenced by handle_overlay_connect().

1485 {
1486  struct OverlayConnectContext *occ = cls;
1487  struct RemotePeer2Context *rp2c;
1489 
1490  GNUNET_assert (OCC_TYPE_LOCAL != occ->type);
1491  rp2c = &occ->p2ctx.remote;
1492  rp2c->ncn = NULL;
1493  rp2c->p2c = c;
1494  cmsg.header.size =
1495  htons (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage));
1496  cmsg.header.type =
1498  cmsg.peer_id = htonl (occ->other_peer_id);
1499  cmsg.operation_id = GNUNET_htonll (occ->op_id);
1500  rp2c->opc =
1502  occ->op_id,
1503  &cmsg.header,
1505  occ);
1506  GNUNET_free_non_null (occ->emsg);
1507  GNUNET_asprintf (&occ->emsg,
1508  "0x%llx: Timeout while getting peer identity of peer "
1509  "with id: %u",
1510  occ->op_id,
1511  occ->other_peer_id);
1512 }
uint64_t op_id
The id of the operation responsible for creating this context.
struct NeighbourConnectNotification * ncn
Notification handle acquire to connect to a remote controller.
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:615
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Context data for operations on second peer in remote overlay connection contexts. ...
struct RemotePeer2Context remote
Context information to be used if the second peer is remote.
char * emsg
The error message we send if this overlay connect operation has timed out.
struct GNUNET_TESTBED_Controller * p2c
Controller of peer 2; If OCC_TYPE_REMOTE_LATERAL is the type of overlay connection then this can be N...
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
enum OverlayConnectContextType type
The type of this context information.
static void overlay_connect_get_config(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded get peer config operation as part of overlay connect is successf...
This type is used if the overlay connection is local i.e.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
#define GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION
Message to get a peer's information.
struct OperationContext * GNUNET_TESTBED_forward_operation_msg_(struct GNUNET_TESTBED_Controller *controller, uint64_t operation_id, const struct GNUNET_MessageHeader *msg, GNUNET_MQ_MessageCallback cc, void *cc_cls)
Sends the given message as an operation.
Definition: testbed_api.c:1349
uint32_t other_peer_id
The id of the second peer which has to connect to the first peer.
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
struct OperationContext * opc
Operation context for the suboperation we start to get the identity of the second peer...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_overlay_connect()

void handle_overlay_connect ( void *  cls,
const struct GNUNET_TESTBED_OverlayConnectMessage msg 
)

Handler for GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 1522 of file gnunet-service-testbed_oc.c.

References OverlayConnectContext::cgh_ch, OverlayConnectContext::client, Peer::details, OverlayConnectContext::emsg, forward_overlay_connect(), GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_new, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TESTING_peer_get_identity(), GNUNET_YES, GST_connection_pool_get_handle(), GST_CONNECTIONPOOL_SERVICE_CORE, GST_create_neighbour(), GST_get_neighbour(), GST_host_list, GST_neighbour_get_connection(), GST_peer_list, GST_timeout, Peer::id, Peer::is_remote, Peer::local, LOG, LOG_DEBUG, RemotePeer2Context::ncn, occ_cache_get_handle_core_cb(), OCC_TYPE_LOCAL, OCC_TYPE_REMOTE_LATERAL, OCC_TYPE_REMOTE_SLAVE, OverlayConnectContext::op_id, GNUNET_TESTBED_OverlayConnectMessage::operation_id, OverlayConnectContext::other_peer_id, OverlayConnectContext::other_peer_identity, overlay_connect_notify(), p2_controller_connect_cb(), RemotePeer2Context::p2c, OverlayConnectContext::p2ctx, RemotePeer2Context::p2n, peer, OverlayConnectContext::peer, GNUNET_TESTBED_OverlayConnectMessage::peer1, GNUNET_TESTBED_OverlayConnectMessage::peer2, GNUNET_TESTBED_OverlayConnectMessage::peer2_host_id, Peer::reference_cnt, Peer::remote, OverlayConnectContext::remote, timeout_overlay_connect(), OverlayConnectContext::timeout_task, OverlayConnectContext::type, VALID_HOST_ID, and VALID_PEER_ID.

1524 {
1525  struct GNUNET_SERVICE_Client *client = cls;
1526  struct Peer *peer;
1527  struct Peer *peer2;
1528  struct OverlayConnectContext *occ;
1529  struct Neighbour *p2n;
1530  uint64_t operation_id;
1531  uint32_t p1;
1532  uint32_t p2;
1533  uint32_t peer2_host_id;
1534 
1535  p1 = ntohl (msg->peer1);
1536  p2 = ntohl (msg->peer2);
1537  if (! VALID_PEER_ID (p1))
1538  {
1539  GNUNET_break (0);
1540  GNUNET_SERVICE_client_drop (client);
1541  return;
1542  }
1543  peer = GST_peer_list[p1];
1544  operation_id = GNUNET_ntohll (msg->operation_id);
1545  LOG_DEBUG
1546  ("Received overlay connect for peers %u and %u with op id: 0x%llx\n",
1547  p1,
1548  p2,
1549  operation_id);
1550  peer2_host_id = ntohl (msg->peer2_host_id);
1551  if (GNUNET_YES == peer->is_remote)
1552  {
1553  if (! VALID_HOST_ID (peer2_host_id))
1554  {
1555  GNUNET_break (0);
1556  GNUNET_SERVICE_client_drop (client);
1557  return;
1558  }
1559  forward_overlay_connect (msg, client);
1561  return;
1562  }
1563  p2n = NULL;
1564  occ = GNUNET_new (struct OverlayConnectContext);
1565  occ->type = OCC_TYPE_LOCAL;
1566  if (! VALID_PEER_ID (p2)) /* May be peer2 is on a another controller */
1567  {
1568  if (NULL == (p2n = GST_get_neighbour (peer2_host_id)))
1569  {
1570  if (! VALID_HOST_ID (peer2_host_id))
1571  {
1572  GNUNET_break (0);
1574  "0x%llx: Peer %u's host not in our neighbours list\n",
1575  operation_id, p2);
1576  GNUNET_SERVICE_client_drop (client);
1577  GNUNET_free (occ);
1578  return;
1579  }
1580  p2n = GST_create_neighbour (GST_host_list[peer2_host_id]);
1581  }
1583  occ->p2ctx.remote.p2n = p2n;
1584  }
1585  else if (GNUNET_YES == GST_peer_list[p2]->is_remote)
1586  {
1587  occ->type = OCC_TYPE_REMOTE_SLAVE;
1588  occ->p2ctx.remote.p2c = GST_peer_list[p2]->details.remote.slave->controller;
1589  }
1591  occq_tail,
1592  occ);
1593  occ->client = client;
1594  occ->other_peer_id = p2;
1596  occ->peer = GST_peer_list[p1];
1597  occ->op_id = operation_id;
1598  GNUNET_assert (NULL == occ->timeout_task);
1599  occ->timeout_task =
1602  occ);
1603  switch (occ->type)
1604  {
1606  GNUNET_asprintf (&occ->emsg,
1607  "0x%llx: Timeout while acquiring connection to peer %u's "
1608  "host: %u\n",
1609  occ->op_id,
1610  occ->other_peer_id,
1611  peer2_host_id);
1612  occ->p2ctx.remote.ncn
1615  occ);
1616  break;
1617  case OCC_TYPE_REMOTE_SLAVE:
1619  occ->p2ctx.remote.p2c);
1620  break;
1621  case OCC_TYPE_LOCAL:
1622  peer2 = GST_peer_list[occ->other_peer_id];
1623  peer2->reference_cnt++;
1625  &occ->other_peer_identity);
1626  GNUNET_asprintf (&occ->emsg,
1627  "0x%llx: Timeout while connecting to CORE of peer with "
1628  "id: %u",
1629  occ->op_id,
1630  occ->peer->id);
1631  occ->cgh_ch =
1633  occ->peer->details.local.cfg,
1636  &occ->other_peer_identity,
1637  &overlay_connect_notify, occ);
1638  break;
1639  }
1641 }
A connected controller which is not our child.
static void occ_cache_get_handle_core_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed CORE handle set.
int is_remote
Is this peer locally created?
struct NeighbourConnectNotification * ncn
Notification handle acquire to connect to a remote controller.
uint64_t op_id
The id of the operation responsible for creating this context.
struct Peer::@69::@71 remote
Type to be used when the first peer is local and the other peer is on a controller which is not start...
struct GST_ConnectionPool_GetHandle * cgh_ch
The GST_ConnectionPool_GetHandle for registering callback to notify CORE level peer connects and to g...
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Our local reference id for this peer.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct Peer ** GST_peer_list
A list of peers we know about.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:412
#define LOG(kind,...)
Redefine LOG with a changed log component string.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct RemotePeer2Context remote
Context information to be used if the second peer is remote.
char * emsg
The error message we send if this overlay connect operation has timed out.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void timeout_overlay_connect(void *cls)
Task which will be run when overlay connect request has been timed out.
struct GNUNET_SERVICE_Client * client
The client which has requested for overlay connection.
Handle to a client that is connected to a service.
Definition: service.c:249
static void overlay_connect_notify(void *cls, const struct GNUNET_PeerIdentity *new_peer)
Function called to notify transport users that another peer connected to us.
struct GNUNET_TESTBED_Controller * p2c
Controller of peer 2; If OCC_TYPE_REMOTE_LATERAL is the type of overlay connection then this can be N...
static struct OverlayConnectContext * occq_tail
DLL tail for OverlayConnectContext DLL.
uint32_t peer2
Unique ID for the second peer.
Definition: testbed.h:417
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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:1246
struct Peer::@69::@70 local
struct Peer * peer
the first peer which is to expect an overlay connection from the second peer.
uint32_t peer1
Unique ID for the first peer.
Definition: testbed.h:407
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
uint32_t peer2_host_id
The ID of the host which runs peer2.
Definition: testbed.h:422
enum OverlayConnectContextType type
The type of this context information.
struct Neighbour * p2n
The neighbour handle.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
This type is used if the overlay connection is local i.e.
static struct OverlayConnectContext * occq_head
DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
Type to be used when the first peer is local and the other peer is on a slave controller started by u...
#define VALID_HOST_ID(id)
Condition to check if host id is valid.
uint32_t other_peer_id
The id of the second peer which has to connect to the first peer.
static void forward_overlay_connect(const struct GNUNET_TESTBED_OverlayConnectMessage *msg, struct GNUNET_SERVICE_Client *client)
Forwards the overlay connect request to a slave controller.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
union Peer::@69 details
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
Information about preferences and sessions we track per peer.
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Definition: testing.c:1292
#define GNUNET_YES
Definition: gnunet_common.h:80
#define LOG_DEBUG(msg)
static void p2_controller_connect_cb(void *cls, struct GNUNET_TESTBED_Controller *c)
Callback called when a connection to the controller of peer2 has been established.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ cleanup_rocc()

static void cleanup_rocc ( struct RemoteOverlayConnectCtx rocc)
static

Function to cleanup RemoteOverlayConnectCtx and any associated tasks with it.

Parameters
roccthe RemoteOverlayConnectCtx

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

References RemoteOverlayConnectCtx::attempt_connect_task_id, ConnectivitySuggestContext::cgh_p2_ats, ConnectivitySuggestContext::cgh_p2_th, ConnectivitySuggestContext::csh, Peer::destroy_flag, GNUNET_assert, GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_non_null, GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_offer_hello_cancel(), GNUNET_YES, GST_connection_pool_get_handle_done(), GST_destroy_peer(), RemoteOverlayConnectCtx::hello, LOG_DEBUG, RemoteOverlayConnectCtx::ohh, RemoteOverlayConnectCtx::op_id, RemoteOverlayConnectCtx::peer, Peer::reference_cnt, RemoteOverlayConnectCtx::tcc, and RemoteOverlayConnectCtx::timeout_rocc_task_id.

Referenced by cache_transport_peer_connect_notify(), GST_free_roccq(), rocc_cache_get_handle_transport_cb(), and timeout_rocc_task().

1652 {
1653  LOG_DEBUG ("0x%llx: Cleaning up rocc\n",
1654  rocc->op_id);
1655  if (NULL != rocc->attempt_connect_task_id)
1657  if (NULL != rocc->timeout_rocc_task_id)
1659  if (NULL != rocc->ohh)
1661  if (NULL != rocc->tcc.csh)
1665  GNUNET_assert (rocc->peer->reference_cnt > 0);
1666  rocc->peer->reference_cnt--;
1667  if ((GNUNET_YES == rocc->peer->destroy_flag) &&
1668  (0 == rocc->peer->reference_cnt))
1669  GST_destroy_peer (rocc->peer);
1670  GNUNET_free_non_null (rocc->hello);
1672  roccq_tail,
1673  rocc);
1674  GNUNET_free (rocc);
1675 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct RemoteOverlayConnectCtx * roccq_head
DLL head for RequectOverlayConnectContext DLL - to be used to clean up during shutdown.
uint32_t destroy_flag
While destroying a peer, due to the fact that there could be references to this peer, we delay the peer destroy to a further time.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct ConnectivitySuggestContext tcc
The transport try connect context.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
The handle for offering HELLO.
struct GNUNET_SCHEDULER_Task * timeout_rocc_task_id
Task to timeout RequestOverlayConnect.
static struct RemoteOverlayConnectCtx * roccq_tail
DLL tail for RequectOverlayConnectContext DLL.
uint64_t op_id
The id of the operation responsible for creating this context.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
void GNUNET_TRANSPORT_offer_hello_cancel(struct GNUNET_TRANSPORT_OfferHelloHandle *ohh)
Cancel the request to transport to offer the HELLO message.
struct GNUNET_ATS_ConnectivitySuggestHandle * csh
The ATS handle for the connectivity suggestion.
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
struct GNUNET_MessageHeader * hello
Peer A's HELLO.
struct GST_ConnectionPool_GetHandle * cgh_p2_th
The GetCacheHandle for the peer2's transport handle (used to offer the HELLO to the peer)...
#define GNUNET_YES
Definition: gnunet_common.h:80
#define LOG_DEBUG(msg)
void GST_connection_pool_get_handle_done(struct GST_ConnectionPool_GetHandle *gh)
Relinquish a GST_ConnectionPool_GetHandle object.
struct Peer * peer
The peer handle of peer B.
#define GNUNET_free(ptr)
Wrapper around free.
struct GST_ConnectionPool_GetHandle * cgh_p2_ats
The GetCacheHandle for the peer2's ATS handle.
struct GNUNET_SCHEDULER_Task * attempt_connect_task_id
Task for offering HELLO of A to B and doing try_connect.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeout_rocc_task()

static void timeout_rocc_task ( void *  cls)
static

Task to timeout rocc and cleanit up.

Parameters
clsthe RemoteOverlayConnectCtx

Definition at line 1684 of file gnunet-service-testbed_oc.c.

References cleanup_rocc(), GNUNET_assert, LOG_DEBUG, RemoteOverlayConnectCtx::op_id, and RemoteOverlayConnectCtx::timeout_rocc_task_id.

Referenced by handle_remote_overlay_connect(), and rocc_cache_get_handle_transport_cb().

1685 {
1686  struct RemoteOverlayConnectCtx *rocc = cls;
1687 
1688  GNUNET_assert (rocc->timeout_rocc_task_id != NULL);
1689  rocc->timeout_rocc_task_id = NULL;
1690  LOG_DEBUG ("0x%llx: rocc timed out\n",
1691  rocc->op_id);
1692  cleanup_rocc (rocc);
1693 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void cleanup_rocc(struct RemoteOverlayConnectCtx *rocc)
Function to cleanup RemoteOverlayConnectCtx and any associated tasks with it.
struct GNUNET_SCHEDULER_Task * timeout_rocc_task_id
Task to timeout RequestOverlayConnect.
uint64_t op_id
The id of the operation responsible for creating this context.
Context information for remote overlay connect operations.
#define LOG_DEBUG(msg)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cache_transport_peer_connect_notify()

static void cache_transport_peer_connect_notify ( void *  cls,
const struct GNUNET_PeerIdentity new_peer 
)
static

Function called to notify transport users that another peer connected to us.

Parameters
clsthe RemoteOverlayConnectContext
new_peerthe peer that connected

Definition at line 1704 of file gnunet-service-testbed_oc.c.

References RemoteOverlayConnectCtx::a_id, attempt_connect_task(), cleanup_rocc(), GNUNET_assert, GNUNET_i2s(), LOG_DEBUG, and RemoteOverlayConnectCtx::op_id.

Referenced by handle_remote_overlay_connect().

1706 {
1707  struct RemoteOverlayConnectCtx *rocc = cls;
1708 
1709  LOG_DEBUG ("0x%llx: Request Overlay connect notify\n",
1710  rocc->op_id);
1711  GNUNET_assert (0 ==
1712  memcmp (new_peer, &rocc->a_id,
1713  sizeof (struct GNUNET_PeerIdentity)));
1714  LOG_DEBUG ("0x%llx: Peer %s connected\n",
1715  rocc->op_id,
1716  GNUNET_i2s (&rocc->a_id));
1717  cleanup_rocc (rocc);
1718 }
struct GNUNET_PeerIdentity a_id
The peer identity of peer A.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void cleanup_rocc(struct RemoteOverlayConnectCtx *rocc)
Function to cleanup RemoteOverlayConnectCtx and any associated tasks with it.
uint64_t op_id
The id of the operation responsible for creating this context.
Context information for remote overlay connect operations.
The identity of the host (wraps the signing key of the peer).
#define LOG_DEBUG(msg)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attempt_connect_task()

static void attempt_connect_task ( void *  cls)
static

Task to offer the HELLO message to the peer and ask it to connect to the peer whose identity is in RemoteOverlayConnectCtx.

Parameters
clsthe RemoteOverlayConnectCtx

Definition at line 1765 of file gnunet-service-testbed_oc.c.

References RemoteOverlayConnectCtx::a_id, RemoteOverlayConnectCtx::attempt_connect_task_id, ConnectivitySuggestContext::cfg, GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_i2s(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_TRANSPORT_offer_hello(), RemoteOverlayConnectCtx::hello, Peer::id, LOG_DEBUG, RemoteOverlayConnectCtx::ohh, RemoteOverlayConnectCtx::op_id, RemoteOverlayConnectCtx::peer, rocc_hello_sent_cb(), and RemoteOverlayConnectCtx::tcc.

Referenced by cache_transport_peer_connect_notify(), and rocc_cache_get_handle_transport_cb().

1766 {
1767  struct RemoteOverlayConnectCtx *rocc = cls;
1768 
1769  GNUNET_assert (NULL != rocc->attempt_connect_task_id);
1770  rocc->attempt_connect_task_id = NULL;
1771  LOG_DEBUG ("0x%llx: Offering HELLO of peer %s to remote peer with id: %u\n",
1772  rocc->op_id,
1773  GNUNET_i2s (&rocc->a_id),
1774  rocc->peer->id);
1775  rocc->ohh =
1777  rocc->hello,
1779  rocc);
1780  if (NULL == rocc->ohh)
1781  rocc->attempt_connect_task_id =
1784  100 +
1787  &attempt_connect_task, rocc);
1788 }
struct GNUNET_PeerIdentity a_id
The peer identity of peer A.
static void attempt_connect_task(void *cls)
Task to offer the HELLO message to the peer and ask it to connect to the peer whose identity is in Re...
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.
uint32_t id
Our local reference id for this peer.
struct ConnectivitySuggestContext tcc
The transport try connect context.
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
The handle for offering HELLO.
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:1246
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:439
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration of the peer from cache.
uint64_t op_id
The id of the operation responsible for creating this context.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
Context information for remote overlay connect operations.
static void rocc_hello_sent_cb(void *cls)
Task that is run when hello has been sent If tc->reason = GNUNET_SCHEDULER_REASON_TIMEOUT then sendin...
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.
struct GNUNET_MessageHeader * hello
Peer A's HELLO.
#define LOG_DEBUG(msg)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct Peer * peer
The peer handle of peer B.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
struct GNUNET_SCHEDULER_Task * attempt_connect_task_id
Task for offering HELLO of A to B and doing try_connect.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocc_hello_sent_cb()

static void rocc_hello_sent_cb ( void *  cls)
static

Task that is run when hello has been sent If tc->reason = GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if GNUNET_SCHEDULER_REASON_READ_READY is succeeded.

Parameters
clsthe overlay connect context

Definition at line 1739 of file gnunet-service-testbed_oc.c.

References RemoteOverlayConnectCtx::a_id, RemoteOverlayConnectCtx::attempt_connect_task_id, ConnectivitySuggestContext::cgh_p2_ats, Peer::details, GNUNET_assert, GNUNET_i2s(), GST_connection_pool_get_handle(), GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY, Peer::id, Peer::local, LOG_DEBUG, occ_cache_get_handle_ats_rocc_cb(), RemoteOverlayConnectCtx::ohh, RemoteOverlayConnectCtx::op_id, RemoteOverlayConnectCtx::peer, and RemoteOverlayConnectCtx::tcc.

Referenced by attempt_connect_task().

1740 {
1741  struct RemoteOverlayConnectCtx *rocc = cls;
1742 
1743  rocc->ohh = NULL;
1744  GNUNET_assert (NULL == rocc->attempt_connect_task_id);
1745  LOG_DEBUG ("0x%llx: HELLO of peer %s delivered to local peer with id: %u\n",
1746  rocc->op_id,
1747  GNUNET_i2s (&rocc->a_id),
1748  rocc->peer->id);
1749  rocc->tcc.cgh_p2_ats =
1751  rocc->peer->details.local.cfg,
1754  rocc, NULL, NULL, NULL);
1755 }
struct GNUNET_PeerIdentity a_id
The peer identity of peer A.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Our local reference id for this peer.
struct ConnectivitySuggestContext tcc
The transport try connect context.
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
The handle for offering HELLO.
struct Peer::@69::@70 local
uint64_t op_id
The id of the operation responsible for creating this context.
Context information for remote overlay connect operations.
static void occ_cache_get_handle_ats_rocc_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed ATS handle set.
union Peer::@69 details
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
#define LOG_DEBUG(msg)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct Peer * peer
The peer handle of peer B.
struct GST_ConnectionPool_GetHandle * cgh_p2_ats
The GetCacheHandle for the peer2's ATS handle.
struct GNUNET_SCHEDULER_Task * attempt_connect_task_id
Task for offering HELLO of A to B and doing try_connect.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocc_cache_get_handle_transport_cb()

static void rocc_cache_get_handle_transport_cb ( void *  cls,
struct GNUNET_CORE_Handle ch,
struct GNUNET_TRANSPORT_CoreHandle th,
struct GNUNET_ATS_ConnectivityHandle ac,
const struct GNUNET_PeerIdentity ignore_,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Callback from cache with needed handles set.

Parameters
clsthe closure passed to GST_cache_get_handle_transport()
chthe handle to CORE. Can be NULL if it is not requested
ththe handle to TRANSPORT. Can be NULL if it is not requested
acthe handle to ATS. Can be NULL if it is not requested
ignore_peer identity which is ignored in this callback

Definition at line 1801 of file gnunet-service-testbed_oc.c.

References RemoteOverlayConnectCtx::a_id, attempt_connect_task(), RemoteOverlayConnectCtx::attempt_connect_task_id, ConnectivitySuggestContext::cfg, cleanup_rocc(), GNUNET_i2s(), GNUNET_SCHEDULER_add_now(), GNUNET_TRANSPORT_core_get_mq(), Peer::id, LOG_DEBUG, RemoteOverlayConnectCtx::op_id, RemoteOverlayConnectCtx::peer, RemoteOverlayConnectCtx::tcc, ConnectivitySuggestContext::th_, timeout_rocc_task(), and RemoteOverlayConnectCtx::timeout_rocc_task_id.

Referenced by handle_remote_overlay_connect().

1807 {
1808  struct RemoteOverlayConnectCtx *rocc = cls;
1809 
1810  if (NULL == th)
1811  {
1812  rocc->timeout_rocc_task_id =
1814  return;
1815  }
1816  rocc->tcc.th_ = th;
1817  rocc->tcc.cfg = cfg;
1818  if (NULL !=
1820  &rocc->a_id))
1821  {
1822  LOG_DEBUG ("0x%llx: Target peer %s already connected to local peer: %u\n",
1823  rocc->op_id,
1824  GNUNET_i2s (&rocc->a_id),
1825  rocc->peer->id);
1826  cleanup_rocc (rocc);
1827  return;
1828  }
1829  rocc->attempt_connect_task_id =
1831 }
struct GNUNET_PeerIdentity a_id
The peer identity of peer A.
static void attempt_connect_task(void *cls)
Task to offer the HELLO message to the peer and ask it to connect to the peer whose identity is in Re...
uint32_t id
Our local reference id for this peer.
struct ConnectivitySuggestContext tcc
The transport try connect context.
static void cleanup_rocc(struct RemoteOverlayConnectCtx *rocc)
Function to cleanup RemoteOverlayConnectCtx and any associated tasks with it.
struct GNUNET_SCHEDULER_Task * timeout_rocc_task_id
Task to timeout RequestOverlayConnect.
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.
Definition: scheduler.c:1273
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration of the peer from cache.
uint64_t op_id
The id of the operation responsible for creating this context.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
Context information for remote overlay connect operations.
struct GNUNET_MQ_Handle * GNUNET_TRANSPORT_core_get_mq(struct GNUNET_TRANSPORT_CoreHandle *handle, const struct GNUNET_PeerIdentity *peer)
Checks if a given peer is connected to us and get the message queue.
#define LOG_DEBUG(msg)
static void timeout_rocc_task(void *cls)
Task to timeout rocc and cleanit up.
struct GNUNET_TRANSPORT_CoreHandle * th_
The transport handle obtained from cache.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct Peer * peer
The peer handle of peer B.
struct GNUNET_SCHEDULER_Task * attempt_connect_task_id
Task for offering HELLO of A to B and doing try_connect.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_remote_overlay_connect()

int check_remote_overlay_connect ( void *  cls,
const struct GNUNET_TESTBED_RemoteOverlayConnectMessage msg 
)

Check GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages.

Parameters
clsidentification of the client
msgthe actual message
Returns
GNUNET_OK if msg is well-formed

Definition at line 1842 of file gnunet-service-testbed_oc.c.

References GNUNET_break, GNUNET_break_op, GNUNET_MESSAGE_TYPE_HELLO, GNUNET_OK, GNUNET_SYSERR, GST_peer_list, GST_peer_list_size, GNUNET_TESTBED_RemoteOverlayConnectMessage::header, GNUNET_TESTBED_RemoteOverlayConnectMessage::hello, GNUNET_TESTBED_RemoteOverlayConnectMessage::peer, peer_id, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

1844 {
1845  uint32_t peer_id;
1846  uint16_t msize;
1847  uint16_t hsize;
1848 
1849  msize = ntohs (msg->header.size);
1850  if (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type))
1851  {
1852  GNUNET_break (0);
1853  return GNUNET_SYSERR;
1854  }
1855  hsize = ntohs (msg->hello->size);
1856  if ((sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hsize) != msize)
1857  {
1858  GNUNET_break (0);
1859  return GNUNET_SYSERR;
1860  }
1861  peer_id = ntohl (msg->peer);
1862  if ((peer_id >= GST_peer_list_size) ||
1863  (NULL == GST_peer_list[peer_id]))
1864  {
1865  GNUNET_break_op (0);
1866  return GNUNET_SYSERR;
1867  }
1868  return GNUNET_OK;
1869 }
Message sent from host controller of a peer(A) to the host controller of another peer(B) to request B...
Definition: testbed.h:431
struct Peer ** GST_peer_list
A list of peers we know about.
unsigned int GST_peer_list_size
The size of the peer list.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
struct GNUNET_MessageHeader hello[0]
To be followed by the HELLO message of A.
Definition: testbed.h:456
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint32_t peer
The Unique ID of B.
Definition: testbed.h:441
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT.
Definition: testbed.h:436

◆ handle_remote_overlay_connect()

void handle_remote_overlay_connect ( void *  cls,
const struct GNUNET_TESTBED_RemoteOverlayConnectMessage msg 
)

Handler for GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 1879 of file gnunet-service-testbed_oc.c.

References RemoteOverlayConnectCtx::a_id, cache_transport_peer_connect_notify(), ConnectivitySuggestContext::cgh_p2_th, Peer::details, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_copy_message(), GNUNET_i2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_strlcpy(), GNUNET_TESTBED_queue_message_(), GNUNET_TESTING_peer_get_identity(), GNUNET_YES, GST_connection_pool_get_handle(), GST_CONNECTIONPOOL_SERVICE_TRANSPORT, GST_peer_list, GST_timeout, GNUNET_TESTBED_RemoteOverlayConnectMessage::header, RemoteOverlayConnectCtx::hello, GNUNET_TESTBED_RemoteOverlayConnectMessage::hello, Peer::is_remote, Peer::local, LOG_DEBUG, RemoteOverlayConnectCtx::op_id, GNUNET_TESTBED_RemoteOverlayConnectMessage::operation_id, peer, RemoteOverlayConnectCtx::peer, GNUNET_TESTBED_RemoteOverlayConnectMessage::peer, peer_id, GNUNET_TESTBED_RemoteOverlayConnectMessage::peer_identity, Peer::reference_cnt, Peer::remote, rocc_cache_get_handle_transport_cb(), GNUNET_MessageHeader::size, RemoteOverlayConnectCtx::tcc, timeout_rocc_task(), and RemoteOverlayConnectCtx::timeout_rocc_task_id.

1881 {
1882  struct GNUNET_SERVICE_Client *client = cls;
1883  struct RemoteOverlayConnectCtx *rocc;
1884  struct Peer *peer;
1885  struct GNUNET_PeerIdentity pid;
1886  static char pid_str[16];
1887  uint32_t peer_id;
1888  uint16_t hsize;
1889 
1890  hsize = ntohs (msg->hello->size);
1891  peer_id = ntohl (msg->peer);
1892  peer = GST_peer_list[peer_id];
1893  if (GNUNET_YES == peer->is_remote)
1894  {
1895  struct GNUNET_MessageHeader *msg2;
1896 
1897  msg2 = GNUNET_copy_message (&msg->header);
1898  GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller,
1899  msg2);
1901  return;
1902  }
1903  rocc = GNUNET_new (struct RemoteOverlayConnectCtx);
1904  rocc->op_id = GNUNET_ntohll (msg->operation_id);
1906  roccq_tail,
1907  rocc);
1908  rocc->a_id = msg->peer_identity;
1910  &pid);
1911  (void) GNUNET_strlcpy (pid_str,
1912  GNUNET_i2s (&pid),
1913  sizeof (pid_str));
1914  LOG_DEBUG ("0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n",
1915  rocc->op_id,
1916  pid_str,
1917  GNUNET_i2s (&rocc->a_id),
1918  hsize);
1919  rocc->peer = peer;
1920  rocc->peer->reference_cnt++;
1921  rocc->hello = GNUNET_malloc (hsize);
1922  GNUNET_memcpy (rocc->hello,
1923  msg->hello,
1924  hsize);
1925  rocc->tcc.cgh_p2_th =
1927  rocc->peer->details.local.cfg,
1930  rocc,
1931  &rocc->a_id,
1933  rocc);
1934  rocc->timeout_rocc_task_id =
1937  rocc);
1939 }
static struct RemoteOverlayConnectCtx * roccq_head
DLL head for RequectOverlayConnectContext DLL - to be used to clean up during shutdown.
int is_remote
Is this peer locally created?
struct GNUNET_PeerIdentity a_id
The peer identity of peer A.
struct Peer::@69::@71 remote
struct ConnectivitySuggestContext tcc
The transport try connect context.
struct Peer ** GST_peer_list
A list of peers we know about.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
struct GNUNET_MessageHeader hello[0]
To be followed by the HELLO message of A.
Definition: testbed.h:456
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_PeerIdentity peer_identity
Identity of A.
Definition: testbed.h:451
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Handle to a client that is connected to a service.
Definition: service.c:249
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:1246
struct Peer::@69::@70 local
#define GNUNET_memcpy(dst, src, n)
uint32_t peer
The Unique ID of B.
Definition: testbed.h:441
struct GNUNET_SCHEDULER_Task * timeout_rocc_task_id
Task to timeout RequestOverlayConnect.
static struct RemoteOverlayConnectCtx * roccq_tail
DLL tail for RequectOverlayConnectContext DLL.
uint64_t operation_id
The Operation ID that is used to identify this operation.
Definition: testbed.h:446
uint64_t op_id
The id of the operation responsible for creating this context.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
static void rocc_cache_get_handle_transport_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *ignore_, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed handles set.
Context information for remote overlay connect operations.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1315
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
union Peer::@69 details
Information about preferences and sessions we track per peer.
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Definition: testing.c:1292
struct GNUNET_MessageHeader * hello
Peer A's HELLO.
Header for all communications.
struct GST_ConnectionPool_GetHandle * cgh_p2_th
The GetCacheHandle for the peer2's transport handle (used to offer the HELLO to the peer)...
#define GNUNET_YES
Definition: gnunet_common.h:80
static void cache_transport_peer_connect_notify(void *cls, const struct GNUNET_PeerIdentity *new_peer)
Function called to notify transport users that another peer connected to us.
#define LOG_DEBUG(msg)
static void timeout_rocc_task(void *cls)
Task to timeout rocc and cleanit up.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
struct Peer * peer
The peer handle of peer B.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT.
Definition: testbed.h:436
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
Here is the call graph for this function:

◆ GST_free_occq()

void GST_free_occq ( void  )

Clears all pending overlay connect contexts in queue.

Definition at line 1946 of file gnunet-service-testbed_oc.c.

References cleanup_occ().

Referenced by handle_shutdown_peers(), and shutdown_task().

1947 {
1948  struct OverlayConnectContext *occ;
1949 
1950  while (NULL != (occ = occq_head))
1951  cleanup_occ (occ);
1952 }
Context information for connecting 2 peers in overlay.
static void cleanup_occ(struct OverlayConnectContext *occ)
Cleanup overlay connect context structure.
static struct OverlayConnectContext * occq_head
DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_free_roccq()

void GST_free_roccq ( void  )

Clears all pending remote overlay connect contexts in queue.

Definition at line 1959 of file gnunet-service-testbed_oc.c.

References cleanup_rocc().

Referenced by handle_shutdown_peers(), and shutdown_task().

1960 {
1961  struct RemoteOverlayConnectCtx *rocc;
1962 
1963  while (NULL != (rocc = roccq_head))
1964  cleanup_rocc (rocc);
1965 }
static struct RemoteOverlayConnectCtx * roccq_head
DLL head for RequectOverlayConnectContext DLL - to be used to clean up during shutdown.
static void cleanup_rocc(struct RemoteOverlayConnectCtx *rocc)
Function to cleanup RemoteOverlayConnectCtx and any associated tasks with it.
Context information for remote overlay connect operations.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ occq_head

struct OverlayConnectContext* occq_head
static

DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown.

Definition at line 334 of file gnunet-service-testbed_oc.c.

◆ occq_tail

struct OverlayConnectContext* occq_tail
static

DLL tail for OverlayConnectContext DLL.

Definition at line 339 of file gnunet-service-testbed_oc.c.

◆ roccq_head

struct RemoteOverlayConnectCtx* roccq_head
static

DLL head for RequectOverlayConnectContext DLL - to be used to clean up during shutdown.

Definition at line 345 of file gnunet-service-testbed_oc.c.

◆ roccq_tail

struct RemoteOverlayConnectCtx* roccq_tail
static

DLL tail for RequectOverlayConnectContext DLL.

Definition at line 350 of file gnunet-service-testbed_oc.c.