GNUnet  0.19.2
gnunet-service-testbed_oc.c File Reference

code for handling overlay connect operations More...

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 successful. 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 cleaning 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 successful. 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 38 of file gnunet-service-testbed_oc.c.

◆ 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.

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 78 of file gnunet-service-testbed_oc.c.

79 {
85 
91 
97 };
@ OCC_TYPE_LOCAL
This type is used if the overlay connection is local i.e.
@ 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 start...
@ 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 u...

Function Documentation

◆ GST_cleanup_focc()

void GST_cleanup_focc ( struct ForwardedOverlayConnectContext focc)

Cleans up ForwardedOverlayConnectContext.

Parameters
foccthe ForwardedOverlayConnectContext to cleanup

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

358 {
359  struct RegisteredHostContext *rhc = focc->rhc;
360 
362  rhc->focc_dll_tail,
363  focc);
364  GNUNET_free (focc->orig_msg);
365  GNUNET_free (focc);
366 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
struct RegisteredHostContext * rhc
Which host does this FOCC belong to?
struct GNUNET_MessageHeader * orig_msg
A copy of the original overlay connect message.
This context information will be created for each host that is registered at slave controllers during...
struct ForwardedOverlayConnectContext * focc_dll_tail
Tail of the ForwardedOverlayConnectContext DLL.
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.

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

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

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 375 of file gnunet-service-testbed_oc.c.

376 {
377  struct ForwardedOperationContext *fopc = cls;
378  struct RegisteredHostContext *rhc;
379  struct ForwardedOverlayConnectContext *focc;
380 
381  fopc->timeout_task = NULL;
382  rhc = fopc->cls;
383  focc = rhc->focc_dll_head;
384  LOG_DEBUG ("Overlay linking between peers %u and %u failed\n",
385  focc->peer1,
386  focc->peer2);
387  GST_cleanup_focc (focc);
389  if (NULL != rhc->focc_dll_head)
391 }
#define LOG_DEBUG(...)
Debug logging shorthand.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
void GST_cleanup_focc(struct ForwardedOverlayConnectContext *focc)
Cleans up ForwardedOverlayConnectContext.
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.
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
Context information to used during operations which forward the overlay connect message.

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

Referenced by GST_process_next_focc().

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 successful.

We have to relay the reply msg back to the client

Parameters
clsForwardedOperationContext
msgthe peer create success message

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

405 {
406  struct ForwardedOperationContext *fopc = cls;
407  struct RegisteredHostContext *rhc;
408  struct ForwardedOverlayConnectContext *focc;
409 
410  rhc = fopc->cls;
412  focc = rhc->focc_dll_head;
413  GST_cleanup_focc (focc);
414  if (NULL != rhc->focc_dll_head)
416 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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.

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

Referenced by GST_process_next_focc().

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 425 of file gnunet-service-testbed_oc.c.

426 {
427  struct ForwardedOperationContext *fopc;
428  struct ForwardedOverlayConnectContext *focc;
429  struct Peer *peer;
430  struct Slave *slave;
431 
432  focc = rhc->focc_dll_head;
433  GNUNET_assert (NULL != focc);
434  GNUNET_assert (RHC_DONE == rhc->state);
436  peer = GST_peer_list[focc->peer1];
437  GNUNET_assert (GNUNET_YES == peer->is_remote);
438  GNUNET_assert (NULL != (slave = peer->details.remote.slave));
439  fopc = GNUNET_new (struct ForwardedOperationContext);
440  fopc->client = focc->client;
441  fopc->operation_id = focc->operation_id;
442  fopc->cls = rhc;
443  fopc->type = OP_OVERLAY_CONNECT;
444  fopc->opc =
446  focc->operation_id,
447  focc->orig_msg,
449  fopc);
450  GNUNET_free (focc->orig_msg);
451  focc->orig_msg = NULL;
453  &
455  fopc);
457  fopcq_tail,
458  fopc);
459 }
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
#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.
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...
static void forwarded_overlay_connect_timeout(void *cls)
Timeout task for cancelling a forwarded overlay connect connect.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
@ GNUNET_YES
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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:1241
enum OperationType type
The type of the operation which is forwarded.
struct OperationContext * opc
The generated operation context.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
uint64_t operation_id
The id of the operation that has been forwarded.
uint64_t operation_id
The id of the operation which created this context information.
struct GNUNET_SERVICE_Client * client
The client handle.
enum RegisteredHostContext::RHCState state
Structure representing a connected(directly-linked) controller.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
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:1370
@ OP_OVERLAY_CONNECT
Overlay connection operation.
Definition: testbed_api.h:79
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References ForwardedOperationContext::client, ForwardedOverlayConnectContext::client, ForwardedOperationContext::cls, Slave::controller, 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, OP_OVERLAY_CONNECT, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, ForwardedOverlayConnectContext::operation_id, ForwardedOverlayConnectContext::orig_msg, peer, ForwardedOverlayConnectContext::peer1, 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().

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 468 of file gnunet-service-testbed_oc.c.

469 {
470  if (NULL != lp2c->ohh)
471  {
473  lp2c->ohh = NULL;
474  }
475  if (NULL != lp2c->tcc.cgh_p2_th)
476  {
478  lp2c->tcc.cgh_p2_th = NULL;
479  }
480  if (NULL != lp2c->tcc.cgh_p2_ats)
481  {
483  lp2c->tcc.cgh_p2_ats = NULL;
484  }
485  if (NULL != lp2c->tcc.csh)
486  {
488  lp2c->tcc.csh = NULL;
489  }
490 }
void GST_connection_pool_get_handle_done(struct GST_ConnectionPool_GetHandle *gh)
Relinquish a GST_ConnectionPool_GetHandle object.
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 GST_ConnectionPool_GetHandle * cgh_p2_ats
The GetCacheHandle for the peer2's ATS handle.
struct GST_ConnectionPool_GetHandle * cgh_p2_th
The GetCacheHandle for the peer2's transport handle (used to offer the HELLO to the peer).
struct GNUNET_ATS_ConnectivitySuggestHandle * csh
The ATS handle for the connectivity suggestion.
struct ConnectivitySuggestContext tcc
The transport ConnectivitySuggestContext.
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
The handle for offering the HELLO of the first peer to the second peer.

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().

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 500 of file gnunet-service-testbed_oc.c.

501 {
502  if (NULL != rp2c->opc)
503  {
505  rp2c->opc = NULL;
506  }
507  if (NULL != rp2c->ncn)
508  {
510  rp2c->ncn = NULL;
511  }
512  if ((NULL != rp2c->p2c) && (NULL != rp2c->p2n))
513  {
515  rp2c->p2n = NULL;
516  }
517 }
struct Neighbour * p2n
The neighbour handle.
struct NeighbourConnectNotification * ncn
Notification handle acquire to connect to a remote controller.
struct OperationContext * opc
Operation context for the suboperation we start to get the identity of the second peer.
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:1407

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().

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.

535 {
536  struct Peer *peer2;
537 
538  LOG_DEBUG ("0x%llx: Cleaning up occ\n",
539  (unsigned long long) occ->op_id);
540  GNUNET_free (occ->emsg);
541  GNUNET_free (occ->hello);
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;
568 
571  cleanup_occ_rp2c (&occ->p2ctx.remote);
572  break;
573  }
575  occq_tail,
576  occ);
577  GNUNET_free (occ);
578 }
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
static void cleanup_occ_lp2c(struct LocalPeer2Context *lp2c)
Cleans up any used handles in local peer2 context.
static struct OverlayConnectContext * occq_tail
DLL tail for OverlayConnectContext DLL.
static struct OverlayConnectContext * occq_head
DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown.
#define PEER_EXPIRED(peer)
Condition for checking if given peer is ready to be destroyed.
static void cleanup_occ_rp2c(struct RemotePeer2Context *rp2c)
Cleans up any used handles in remote peer2 context.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:944
void GNUNET_TRANSPORT_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
Stop receiving updates about changes to our HELLO message.
struct GNUNET_MessageHeader * hello
HELLO of the first peer.
struct RemotePeer2Context remote
Context information to be used if the second peer is remote.
struct LocalPeer2Context local
Context information to be used if the second peer is local.
uint64_t op_id
The id of the operation responsible for creating this context.
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 GST_ConnectionPool_GetHandle * cgh_ch
The GST_ConnectionPool_GetHandle for registering callback to notify CORE level peer connects and to g...
union OverlayConnectContext::@60 p2ctx
Context information for operations on the second peer.
struct GNUNET_SCHEDULER_Task * cleanup_task
The id of the cleanup task.
enum OverlayConnectContextType type
The type of this context information.
struct Peer * peer
the first peer which is to expect an overlay connection from the second peer.
uint32_t other_peer_id
The id of the second peer which has to connect to the first peer.
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
char * emsg
The error message we send if this overlay connect operation has timed out.
struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Get GetHelloHandle to acquire a HELLO of the first peer.
struct GST_ConnectionPool_GetHandle * cgh_p1th
The GST_ConnectionPool_GetHandle for the peer1's transport handle.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts.

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_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, occq_head, occq_tail, 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().

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 cleaning up overlay connect context structure.

Parameters
clsthe overlay connect context

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

588 {
589  struct OverlayConnectContext *occ = cls;
590 
591  occ->cleanup_task = NULL;
592  cleanup_occ (occ);
593 }
static void cleanup_occ(struct OverlayConnectContext *occ)
Cleanup overlay connect context structure.
Context information for connecting 2 peers in overlay.

References cleanup_occ(), and OverlayConnectContext::cleanup_task.

Referenced by occ_cache_get_handle_core_cb(), and overlay_connect_notify().

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 602 of file gnunet-service-testbed_oc.c.

603 {
604  struct OverlayConnectContext *occ = cls;
605 
606  GNUNET_assert (NULL != occ->timeout_task);
607  occ->timeout_task = NULL;
608  /* LOG (GNUNET_ERROR_TYPE_WARNING, */
609  /* "0x%llx: Timeout while connecting peers %u and %u: %s\n", occ->op_id, */
610  /* occ->peer->id, occ->other_peer_id, occ->emsg); */
612  occ->op_id,
613  occ->emsg);
614  cleanup_occ (occ);
615 }
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_SERVICE_Client * client
The client which has requested for overlay connection.

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().

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 624 of file gnunet-service-testbed_oc.c.

625 {
626  struct ForwardedOperationContext *fopc;
627  struct ForwardedOperationContext *fopcn;
628  struct OverlayConnectContext *occ;
629  struct OverlayConnectContext *occn;
630 
631  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
632  {
633  fopcn = fopc->next;
634  if (fopc->client == client)
635  {
638  }
639  }
640  for (occ = occq_head; NULL != occ; occ = occn)
641  {
642  occn = occ->next;
643  if (occ->client == client)
644  cleanup_occ (occ);
645  }
646  // FIXME: implement clean up for client_keep replacements!
647 }
struct ForwardedOperationContext * next
The next pointer for DLL.
struct OverlayConnectContext * next
The next pointer for maintaining a DLL of all OverlayConnectContexts.

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

Referenced by client_disconnect_cb().

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 654 of file gnunet-service-testbed_oc.c.

655 {
656  struct GNUNET_MQ_Envelope *env;
658 
659  LOG_DEBUG ("0x%llx: Peers connected - Sending overlay connect success\n",
660  (unsigned long long) occ->op_id);
661  env = GNUNET_MQ_msg (msg,
663  msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT);
664  msg->peer1 = htonl (occ->peer->id);
665  msg->peer2 = htonl (occ->other_peer_id);
666  msg->operation_id = GNUNET_htonll (occ->op_id);
668  env);
669 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
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:304
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:77
#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:2443
@ GNUNET_TESTBED_ET_CONNECT
A connection between two peers was established.
Event notification from a controller to a client.
Definition: testbed.h:476
uint32_t id
Our local reference id for this peer.

References OverlayConnectContext::client, env, 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, OverlayConnectContext::other_peer_id, and OverlayConnectContext::peer.

Referenced by occ_cache_get_handle_core_cb(), and overlay_connect_notify().

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 680 of file gnunet-service-testbed_oc.c.

682 {
683  struct OverlayConnectContext *occ = cls;
684  char *new_peer_str;
685  char *other_peer_str;
686 
687  LOG_DEBUG ("Overlay connect notify\n");
688  if (0 ==
689  GNUNET_memcmp (new_peer,
690  &occ->peer_identity))
691  return;
692  new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer));
693  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
694  if (0 !=
695  GNUNET_memcmp (new_peer,
696  &occ->other_peer_identity))
697  {
698  LOG_DEBUG ("Unexpected peer %s connected when expecting peer %s\n",
699  new_peer_str,
700  other_peer_str);
701  GNUNET_free (new_peer_str);
702  GNUNET_free (other_peer_str);
703  return;
704  }
705  GNUNET_free (new_peer_str);
706  LOG_DEBUG ("0x%llx: Peer %s connected to peer %s\n",
707  (unsigned long long) occ->op_id,
708  other_peer_str,
709  GNUNET_i2s (&occ->peer_identity));
710  GNUNET_free (other_peer_str);
711  if (NULL != occ->send_hello_task)
712  {
714  occ->send_hello_task = NULL;
715  }
716  GNUNET_assert (NULL != occ->timeout_task);
718  occ->timeout_task = NULL;
719  switch (occ->type)
720  {
721  case OCC_TYPE_LOCAL:
722  cleanup_occ_lp2c (&occ->p2ctx.local);
723  break;
724 
727  cleanup_occ_rp2c (&occ->p2ctx.remote);
728  break;
729  }
730  GNUNET_free (occ->emsg);
731  occ->emsg = NULL;
734  occ);
735 }
static void send_overlay_connect_success_msg(struct OverlayConnectContext *occ)
FIXME.
static void do_cleanup_occ(void *cls)
Task for cleaning up overlay connect context structure.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#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:1268
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
struct GNUNET_PeerIdentity peer_identity
The peer identity of the first peer.

References cleanup_occ_lp2c(), cleanup_occ_rp2c(), OverlayConnectContext::cleanup_task, do_cleanup_occ(), OverlayConnectContext::emsg, GNUNET_assert, GNUNET_free, GNUNET_i2s(), GNUNET_memcmp, 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().

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 749 of file gnunet-service-testbed_oc.c.

755 {
756  struct OverlayConnectContext *occ = cls;
757  struct LocalPeer2Context *lp2c;
758 
760  GNUNET_assert (NULL != occ->timeout_task);
761  GNUNET_free (occ->emsg);
762  if (NULL == ac)
763  {
764  GNUNET_asprintf (&occ->emsg,
765  "0x%llx: Failed to connect to ATS of peer with id: %u",
766  (unsigned long long) occ->op_id,
767  occ->peer->id);
769  occ->timeout_task =
771  occ);
772  return;
773  }
774  occ->emsg = NULL;
775 
776  GNUNET_asprintf (&occ->emsg,
777  "0x%llx: Timeout during GNUNET_ATS_connectivity_suggest() at peer %s",
778  (unsigned long long) occ->op_id,
780 
781  lp2c = &occ->p2ctx.local;
782  lp2c->tcc.csh =
784  &occ->peer_identity,
785  1);
786 }
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
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 int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
Context data for operations on second peer in local overlay connection contexts.

References ac, ConnectivitySuggestContext::csh, OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_ATS_connectivity_suggest(), GNUNET_free, 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().

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 799 of file gnunet-service-testbed_oc.c.

805 {
806  struct RemoteOverlayConnectCtx *rocc = cls;
807 
808  rocc->tcc.csh =
810  &rocc->a_id,
811  1);
812 }
Context information for remote overlay connect operations.
struct ConnectivitySuggestContext tcc
The transport try connect context.
struct GNUNET_PeerIdentity a_id
The peer identity of peer A.

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

Referenced by rocc_hello_sent_cb().

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 912 of file gnunet-service-testbed_oc.c.

913 {
914  struct OverlayConnectContext *occ = cls;
915  struct LocalPeer2Context *lp2c;
916  char *other_peer_str;
917 
918  occ->send_hello_task = NULL;
919  GNUNET_assert (NULL != occ->timeout_task);
920  GNUNET_assert (NULL != occ->hello);
921  if (OCC_TYPE_LOCAL != occ->type)
922  {
923  send_hello_thru_rocc (occ);
924  return;
925  }
926  lp2c = &occ->p2ctx.local;
927  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
928  LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n",
929  (unsigned long long) occ->op_id,
930  GNUNET_i2s (&occ->peer_identity),
931  other_peer_str);
932  GNUNET_free (other_peer_str);
933  lp2c->ohh =
935  occ->hello,
937  occ);
938  if (NULL == lp2c->ohh)
939  {
940  GNUNET_break (0);
941  occ->send_hello_task =
944  100
947  &send_hello, occ);
948  }
949 }
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.
static void send_hello_thru_rocc(struct OverlayConnectContext *occ)
Sends the HELLO of peer1 to peer2's controller through remote overlay connect request.
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...
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
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:484
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.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration of the peer from cache.

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 p2_transport_connect(), and p2_transport_connect_cache_callback().

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 833 of file gnunet-service-testbed_oc.c.

834 {
835  struct OverlayConnectContext *occ = cls;
836  struct LocalPeer2Context *lp2c;
837  struct Peer *peer2;
838 
840  GNUNET_assert (NULL != occ->timeout_task);
841  lp2c = &occ->p2ctx.local;
842  lp2c->ohh = NULL;
843 
844  GNUNET_assert (NULL == occ->send_hello_task);
845  GNUNET_free (occ->emsg);
846 
847  GNUNET_asprintf (&occ->emsg,
848  "0x%llx: Timeout while acquiring ATS of %s from cache",
849  (unsigned long long) occ->op_id,
851  GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
852  lp2c->tcc.cgh_p2_ats =
854  peer2->details.local.cfg,
857  occ, NULL, NULL, NULL);
858 }
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.
@ GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY
ATS service.
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.
union Peer::@57 details
struct Peer::@57::@58 local

References ConnectivitySuggestContext::cgh_p2_ats, Peer::details, OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_free, 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().

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 869 of file gnunet-service-testbed_oc.c.

870 {
872  char *other_peer_str;
873  uint16_t msize;
874  uint16_t hello_size;
875 
877  GNUNET_assert (NULL != occ->hello);
878  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
879  LOG_DEBUG (
880  "0x%llx: Offering HELLO of %s (size: %u) to %s via Remote Overlay Request\n",
881  (unsigned long long) 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)
888  + hello_size;
889  msg = GNUNET_malloc (msize);
890  msg->header.type =
892  msg->header.size = htons (msize);
893  msg->peer = htonl (occ->other_peer_id);
894  msg->operation_id = GNUNET_htonll (occ->op_id);
895  msg->peer_identity = occ->peer_identity;
896  GNUNET_memcpy (msg->hello,
897  occ->hello,
898  hello_size);
900  &msg->header);
901 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_malloc(size)
Wrapper around malloc.
#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...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Message sent from host controller of a peer(A) to the host controller of another peer(B) to request B...
Definition: testbed.h:409
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:1336

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, GNUNET_MessageHeader::type, and OverlayConnectContext::type.

Referenced by send_hello().

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 963 of file gnunet-service-testbed_oc.c.

970 {
971  struct OverlayConnectContext *occ = cls;
972 
974  if (NULL == th)
975  {
976  GNUNET_asprintf (&occ->emsg,
977  "0x%llx: Cannot connect to TRANSPORT of %s",
978  (unsigned long long) occ->op_id,
981  occ->timeout_task =
983  return;
984  }
985  occ->p2ctx.local.tcc.th_ = th;
986  occ->p2ctx.local.tcc.cfg = cfg;
987  GNUNET_asprintf (&occ->emsg,
988  "0x%llx: Timeout while offering HELLO to %s",
989  (unsigned long long) occ->op_id,
992 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_TRANSPORT_CoreHandle * th_
The transport handle obtained from cache.

References cfg, 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().

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 1002 of file gnunet-service-testbed_oc.c.

1003 {
1004  struct Peer *peer2;
1005 
1006  /* HUH? Why to *obtain* HELLO? Seems we use this to *SEND* the
1007  HELLO! */
1009  "Connecting to transport of peer %s to obtain HELLO\n",
1011  GNUNET_assert (NULL == occ->emsg);
1012  GNUNET_assert (NULL != occ->hello);
1013  GNUNET_assert (NULL == occ->ghh);
1014  GNUNET_assert (NULL == occ->p1th_);
1015  GNUNET_assert (NULL == occ->cgh_p1th);
1016  if (OCC_TYPE_LOCAL == occ->type)
1017  {
1018  GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
1019  occ->p2ctx.local.tcc.cgh_p2_th =
1021  peer2->details.local.cfg,
1024  occ, NULL, NULL, NULL);
1025  return;
1026  }
1027  GNUNET_asprintf (&occ->emsg,
1028  "0x%llx: Timeout while offering HELLO to %s",
1029  (unsigned long long) occ->op_id,
1032 }
@ GST_CONNECTIONPOOL_SERVICE_TRANSPORT
Transport service.
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.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
struct GNUNET_TRANSPORT_CoreHandle * p1th_
Transport handle of the first peer obtained from cache to get its HELLO.

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().

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 1044 of file gnunet-service-testbed_oc.c.

1047 {
1048  int *empty = cls;
1049 
1050  *empty = GNUNET_NO;
1051  return GNUNET_OK;
1052 }
@ GNUNET_OK
@ GNUNET_NO

References GNUNET_NO, and GNUNET_OK.

Referenced by GNUNET_ATS_solver_generate_property_start(), hello_update_cb(), and set_prop_task().

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 1064 of file gnunet-service-testbed_oc.c.

1066 {
1067  struct OverlayConnectContext *occ = cls;
1068  int empty;
1069  uint16_t msize;
1070 
1071  msize = ntohs (hello->size);
1072  empty = GNUNET_YES;
1073  (void) GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *)
1074  hello, GNUNET_NO,
1075  &test_address,
1076  &empty);
1077  if (GNUNET_YES == empty)
1078  {
1079  LOG_DEBUG ("0x%llx: HELLO of %s is empty\n",
1080  (unsigned long long) occ->op_id,
1081  GNUNET_i2s (&occ->peer_identity));
1082  return;
1083  }
1084  LOG_DEBUG ("0x%llx: Received HELLO of %s\n",
1085  (unsigned long long) occ->op_id,
1086  GNUNET_i2s (&occ->peer_identity));
1087  occ->hello = GNUNET_malloc (msize);
1088  GST_cache_add_hello (occ->peer->id, hello);
1089  GNUNET_memcpy (occ->hello, hello, msize);
1091  occ->ghh = NULL;
1093  occ->cgh_p1th = NULL;
1094  occ->p1th_ = NULL;
1095  GNUNET_free (occ->emsg);
1096  occ->emsg = NULL;
1097  p2_transport_connect (occ);
1098 }
void GST_cache_add_hello(const unsigned int peer_id, const struct GNUNET_MessageHeader *hello)
Caches the HELLO of the given peer.
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.
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.
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
A HELLO message is used to exchange information about transports with other peers.

References OverlayConnectContext::cgh_p1th, OverlayConnectContext::emsg, OverlayConnectContext::ghh, GNUNET_free, 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().

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 1111 of file gnunet-service-testbed_oc.c.

1118 {
1119  struct OverlayConnectContext *occ = cls;
1120 
1121  GNUNET_free (occ->emsg);
1122  occ->emsg = NULL;
1123  if (NULL == th)
1124  {
1125  GNUNET_asprintf (&occ->emsg,
1126  "0x%llx: Cannot connect to TRANSPORT of %s",
1127  (unsigned long long) occ->op_id,
1128  GNUNET_i2s (&occ->peer_identity));
1130  occ->timeout_task =
1132  return;
1133  }
1134  GNUNET_assert (NULL == occ->p1th_);
1135  GNUNET_assert (NULL != occ->cgh_p1th);
1136  occ->p1th_ = th;
1137  GNUNET_asprintf (&occ->emsg,
1138  "0x%llx: Timeout while acquiring HELLO of peer %s",
1139  (unsigned long long) occ->op_id,
1140  GNUNET_i2s (&occ->peer_identity));
1143  &hello_update_cb,
1144  occ);
1145 }
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.
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.
@ GNUNET_TRANSPORT_AC_ANY
Bitmask for "any" address.

References cfg, OverlayConnectContext::cgh_p1th, OverlayConnectContext::emsg, OverlayConnectContext::ghh, GNUNET_asprintf(), GNUNET_assert, GNUNET_free, 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().

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 1158 of file gnunet-service-testbed_oc.c.

1164 {
1165  struct OverlayConnectContext *occ = cls;
1166  const struct GNUNET_MessageHeader *hello;
1167 
1168  GNUNET_assert (NULL != occ->timeout_task);
1169  GNUNET_free (occ->emsg);
1170  if ((NULL == ch) || (NULL == my_identity))
1171  {
1172  GNUNET_asprintf (&occ->emsg,
1173  "0x%llx: Failed to connect to CORE of peer with "
1174  "id: %u",
1175  (unsigned long long) occ->op_id,
1176  occ->peer->id);
1178  occ->timeout_task =
1180  return;
1181  }
1182  occ->emsg = NULL;
1183  occ->peer_identity = *my_identity;
1184  if (NULL !=
1186  &occ->other_peer_identity))
1187  {
1188  LOG_DEBUG ("0x%llx: Target peer %s already connected\n",
1189  (unsigned long long) occ->op_id,
1191  LOG_DEBUG ("0x%llx: Target peer %s connected\n",
1192  (unsigned long long) occ->op_id,
1193  GNUNET_i2s (&occ->peer_identity));
1195  occ->timeout_task = NULL;
1198  return;
1199  }
1200  LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n",
1201  (unsigned long long) occ->op_id,
1202  GNUNET_i2s (&occ->peer_identity));
1203  /* Lookup for HELLO in hello cache */
1204  if (NULL != (hello = GST_cache_lookup_hello (occ->peer->id)))
1205  {
1206  LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n",
1207  (unsigned long long) occ->op_id,
1208  GNUNET_i2s (&occ->peer_identity));
1209  occ->hello = GNUNET_copy_message (hello);
1210  p2_transport_connect (occ);
1211  return;
1212  }
1213  GNUNET_asprintf (&occ->emsg,
1214  "0x%llx: Timeout while acquiring TRANSPORT of %s from cache",
1215  (unsigned long long) occ->op_id,
1216  GNUNET_i2s (&occ->peer_identity));
1217  occ->cgh_p1th =
1219  occ->peer->details.local.cfg,
1222  occ,
1223  NULL, NULL, NULL);
1224 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static struct GNUNET_PeerIdentity my_identity
Identity of this 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.
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:760
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
Header for all communications.

References OverlayConnectContext::cgh_p1th, ch, OverlayConnectContext::cleanup_task, Peer::details, do_cleanup_occ(), OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_copy_message(), GNUNET_CORE_get_mq(), GNUNET_free, 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().

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 successful.

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 1236 of file gnunet-service-testbed_oc.c.

1238 {
1239  struct OverlayConnectContext *occ = cls;
1240  struct RemotePeer2Context *rp2c;
1242 
1243  GNUNET_assert (OCC_TYPE_LOCAL != occ->type);
1244  rp2c = &occ->p2ctx.remote;
1245  rp2c->opc = NULL;
1246  GNUNET_assert (NULL != occ->timeout_task);
1248  {
1250  occ->timeout_task =
1252  }
1253  cmsg =
1255  occ->other_peer_identity = cmsg->peer_identity;
1256  GNUNET_free (occ->emsg);
1257  GNUNET_asprintf (&occ->emsg,
1258  "0x%llx: Timeout while connecting to CORE of peer with "
1259  "id: %u",
1260  (unsigned long long) occ->op_id,
1261  occ->peer->id);
1262  occ->cgh_ch =
1264  occ->peer->details.local.cfg,
1267  occ,
1268  &occ->other_peer_identity,
1270  occ);
1271 }
@ GST_CONNECTIONPOOL_SERVICE_CORE
Core service.
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.
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.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer's information.
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:604
struct GNUNET_PeerIdentity peer_identity
Identity of the peer.
Definition: testbed.h:623
Context data for operations on second peer in remote overlay connection contexts.

References OverlayConnectContext::cgh_ch, Peer::details, OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_free, 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, msg, 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, GNUNET_MessageHeader::type, and OverlayConnectContext::type.

Referenced by p2_controller_connect_cb().

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 1281 of file gnunet-service-testbed_oc.c.

1282 {
1283  struct RegisteredHostContext *rhc = cls;
1284 
1285  rhc->state = RHC_DONE;
1286  GST_process_next_focc (rhc);
1287 }
@ RHC_DONE
State where we attempt to do the overlay connection again.

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

Referenced by register_host().

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 1301 of file gnunet-service-testbed_oc.c.

1304 {
1305  struct RegisteredHostContext **rh = cls;
1306  struct RegisteredHostContext *rh_val = value;
1307 
1308  if ((rh_val->host == (*rh)->host) && (rh_val->reg_host == (*rh)->reg_host))
1309  {
1310  GNUNET_free (*rh);
1311  *rh = rh_val;
1312  return GNUNET_NO;
1313  }
1314  return GNUNET_YES;
1315 }
static char * value
Value of the record to add/remove.
struct GNUNET_TESTBED_Host * host
The host of the controller which has to connect to the above rhost.
struct GNUNET_TESTBED_Host * reg_host
The host which is being registered.

Referenced by register_host().

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 1301 of file gnunet-service-testbed_oc.c.

1328 {
1329  struct GNUNET_HashCode hash;
1330  uint32_t host_ids[2];
1331 
1332  host_ids[0] = GNUNET_TESTBED_host_get_id_ (reg_host);
1333  host_ids[1] = GNUNET_TESTBED_host_get_id_ (host);
1334  GNUNET_CRYPTO_hash (host_ids, sizeof(host_ids), &hash);
1335  return hash;
1336 }
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
A 512-bit hashcode.
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain a host's unique global ID.

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

Referenced by register_host().

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 1353 of file gnunet-service-testbed_oc.c.

1355 {
1356  struct GNUNET_HashCode hash;
1357  struct RegisteredHostContext *rhc;
1358 
1359  rhc = GNUNET_new (struct RegisteredHostContext);
1360  rhc->reg_host = host;
1361  rhc->host = GST_host_list[slave->host_id];
1362  GNUNET_assert (NULL != rhc->reg_host);
1363  GNUNET_assert (NULL != rhc->host);
1364  rhc->state = RHC_INIT;
1365  hash = hash_hosts (rhc->reg_host, rhc->host);
1366  if ((GNUNET_NO ==
1368  &hash)) ||
1369  (GNUNET_SYSERR !=
1371  &hash,
1373  &rhc)))
1374  {
1375  /* create and add a new registered host context */
1376  /* add the focc to its queue */
1378  &hash,
1379  rhc,
1383  rhc,
1384  rhc->reg_host);
1385  }
1386  else
1387  {
1388  /* rhc is now set to the existing one from the hash map by
1389  * reghost_match_iterator() */
1390  /* if queue is empty then ignore creating focc and proceed with normal
1391  * forwarding */
1392  if (RHC_DONE == rhc->state)
1393  return NULL;
1394  }
1395  return rhc;
1396 }
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
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.
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.
static int reghost_match_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator to match a registered host context.
static void host_registration_comp(void *cls, const char *emsg)
Callback which will be called after a host registration succeeded or failed.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_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).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_SYSERR
@ RHC_INIT
The initial state.
uint32_t host_id
The id of the host this controller is running on.
struct GNUNET_CONTAINER_MultiHashMap * reghost_map
Hashmap to hold Registered host contexts.

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(), 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().

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 1409 of file gnunet-service-testbed_oc.c.

1411 {
1412  struct ForwardedOperationContext *fopc;
1413  struct Route *route_to_peer2_host;
1414  struct Route *route_to_peer1_host;
1415  struct Peer *peer;
1416  struct RegisteredHostContext *rhc;
1417  struct ForwardedOverlayConnectContext *focc;
1418  uint64_t op_id;
1419  uint32_t peer2_host_id;
1420  uint32_t p1;
1421  uint32_t p2;
1422 
1423  p1 = ntohl (msg->peer1);
1424  p2 = ntohl (msg->peer2);
1425  op_id = GNUNET_ntohll (msg->operation_id);
1426  peer2_host_id = ntohl (msg->peer2_host_id);
1429  peer = GST_peer_list[p1];
1430  GNUNET_assert (GNUNET_YES == peer->is_remote);
1431  LOG_DEBUG ("0x%llx: Forwarding overlay connect\n",
1432  (unsigned long long) op_id);
1433  route_to_peer2_host = GST_find_dest_route (peer2_host_id);
1434  route_to_peer1_host = GST_find_dest_route
1435  (peer->details.remote.remote_host_id);
1436  GNUNET_assert (NULL != route_to_peer1_host);
1437  if ((NULL != route_to_peer2_host) &&
1438  (route_to_peer1_host->dest == route_to_peer2_host->dest))
1439  goto forward;
1440  /* Peer2 is either with us OR peer1 and peer2 can be reached through
1441  different subtrees OR peer2 is on a subtree unknown to us */
1442  if (NULL != (rhc = register_host (peer->details.remote.slave,
1444  {
1445  LOG_DEBUG ("Queueing forwarding FOCC for connecting peers %u and %u\n", p1,
1446  p2);
1448  focc->rhc = rhc;
1449  focc->peer1 = p1;
1450  focc->peer2 = p2;
1451  focc->peer2_host_id = peer2_host_id;
1452  focc->orig_msg = GNUNET_copy_message (&msg->header);
1453  focc->operation_id = op_id;
1454  focc->client = client;
1456  rhc->focc_dll_tail,
1457  focc);
1458  return;
1459  }
1460 
1461 forward:
1462  LOG_DEBUG ("Forwarding without FOCC for connecting peers %u and %u\n", p1,
1463  p2);
1464  fopc = GNUNET_new (struct ForwardedOperationContext);
1465  fopc->client = client;
1466  fopc->operation_id = op_id;
1467  fopc->type = OP_OVERLAY_CONNECT;
1468  fopc->opc =
1470  slave->controller, op_id,
1471  &msg->header,
1473  fopc);
1474  fopc->timeout_task =
1477  fopc);
1479  fopcq_tail,
1480  fopc);
1481 }
static int forward
Search direction: forward.
Definition: gnunet-abd.c:162
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...
#define VALID_HOST_ID(id)
Condition to check if host id is valid.
static struct RegisteredHostContext * register_host(struct Slave *slave, struct GNUNET_TESTBED_Host *host)
Checks if the given host is registered at the given slave.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
uint32_t peer2_host_id
Id of the host where peer2 is running.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
A routing entry.
uint32_t dest
destination host

References ForwardedOperationContext::client, ForwardedOverlayConnectContext::client, GNUNET_TESTBED_Peer::controller, Route::dest, RegisteredHostContext::focc_dll_head, RegisteredHostContext::focc_dll_tail, fopcq_head, fopcq_tail, forward, 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, LOG_DEBUG, msg, OP_OVERLAY_CONNECT, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, ForwardedOverlayConnectContext::operation_id, ForwardedOverlayConnectContext::orig_msg, peer, ForwardedOverlayConnectContext::peer1, ForwardedOverlayConnectContext::peer2, ForwardedOverlayConnectContext::peer2_host_id, register_host(), ForwardedOverlayConnectContext::rhc, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, VALID_HOST_ID, and VALID_PEER_ID.

Referenced by handle_overlay_connect().

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 1492 of file gnunet-service-testbed_oc.c.

1494 {
1495  struct OverlayConnectContext *occ = cls;
1496  struct RemotePeer2Context *rp2c;
1498 
1499  GNUNET_assert (OCC_TYPE_LOCAL != occ->type);
1500  rp2c = &occ->p2ctx.remote;
1501  rp2c->ncn = NULL;
1502  rp2c->p2c = c;
1503  cmsg.header.size =
1504  htons (sizeof(struct GNUNET_TESTBED_PeerGetConfigurationMessage));
1505  cmsg.header.type =
1507  cmsg.peer_id = htonl (occ->other_peer_id);
1508  cmsg.operation_id = GNUNET_htonll (occ->op_id);
1509  rp2c->opc =
1511  occ->op_id,
1512  &cmsg.header,
1514  occ);
1515  GNUNET_free (occ->emsg);
1516  GNUNET_asprintf (&occ->emsg,
1517  "0x%llx: Timeout while getting peer identity of peer "
1518  "with id: %u",
1519  (unsigned long long) occ->op_id,
1520  occ->other_peer_id);
1521 }
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...
#define GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION
Message to get a peer's information.
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:582

References OverlayConnectContext::emsg, GNUNET_asprintf(), GNUNET_assert, GNUNET_free, 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, GNUNET_MessageHeader::type, and OverlayConnectContext::type.

Referenced by handle_overlay_connect().

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 1531 of file gnunet-service-testbed_oc.c.

1533 {
1534  struct GNUNET_SERVICE_Client *client = cls;
1535  struct Peer *peer;
1536  struct Peer *peer2;
1537  struct OverlayConnectContext *occ;
1538  struct Neighbour *p2n;
1539  uint64_t operation_id;
1540  uint32_t p1;
1541  uint32_t p2;
1542  uint32_t peer2_host_id;
1543 
1544  p1 = ntohl (msg->peer1);
1545  p2 = ntohl (msg->peer2);
1546  if (p1 == p2)
1547  {
1548  GNUNET_break (0);
1549  GNUNET_SERVICE_client_drop (client);
1550  return;
1551  }
1552  if (! VALID_PEER_ID (p1))
1553  {
1554  GNUNET_break (0);
1555  GNUNET_SERVICE_client_drop (client);
1556  return;
1557  }
1558  peer = GST_peer_list[p1];
1559  operation_id = GNUNET_ntohll (msg->operation_id);
1560  LOG_DEBUG
1561  ("Received overlay connect for peers %u and %u with op id: 0x%llx\n",
1562  p1,
1563  p2,
1564  (unsigned long long) operation_id);
1565  peer2_host_id = ntohl (msg->peer2_host_id);
1566  if (GNUNET_YES == peer->is_remote)
1567  {
1568  if (! VALID_HOST_ID (peer2_host_id))
1569  {
1570  GNUNET_break (0);
1571  GNUNET_SERVICE_client_drop (client);
1572  return;
1573  }
1574  forward_overlay_connect (msg, client);
1576  return;
1577  }
1578  p2n = NULL;
1579  occ = GNUNET_new (struct OverlayConnectContext);
1580  occ->type = OCC_TYPE_LOCAL;
1581  if (! VALID_PEER_ID (p2)) /* May be peer2 is on a another controller */
1582  {
1583  if (NULL == (p2n = GST_get_neighbour (peer2_host_id)))
1584  {
1585  if (! VALID_HOST_ID (peer2_host_id))
1586  {
1587  GNUNET_break (0);
1589  "0x%llx: Peer %u's host not in our neighbours list\n",
1590  (unsigned long long) operation_id, p2);
1591  GNUNET_SERVICE_client_drop (client);
1592  GNUNET_free (occ);
1593  return;
1594  }
1595  p2n = GST_create_neighbour (GST_host_list[peer2_host_id]);
1596  }
1598  occ->p2ctx.remote.p2n = p2n;
1599  }
1600  else if (GNUNET_YES == GST_peer_list[p2]->is_remote)
1601  {
1602  occ->type = OCC_TYPE_REMOTE_SLAVE;
1603  occ->p2ctx.remote.p2c = GST_peer_list[p2]->details.remote.slave->controller;
1604  }
1606  occq_tail,
1607  occ);
1608  occ->client = client;
1609  occ->other_peer_id = p2;
1611  occ->peer = GST_peer_list[p1];
1612  occ->op_id = operation_id;
1613  GNUNET_assert (NULL == occ->timeout_task);
1614  occ->timeout_task =
1617  occ);
1618  switch (occ->type)
1619  {
1621  GNUNET_asprintf (&occ->emsg,
1622  "0x%llx: Timeout while acquiring connection to peer %u's "
1623  "host: %u\n",
1624  (unsigned long long) occ->op_id,
1625  occ->other_peer_id,
1626  peer2_host_id);
1627  occ->p2ctx.remote.ncn
1630  occ);
1631  break;
1632  case OCC_TYPE_REMOTE_SLAVE:
1634  occ->p2ctx.remote.p2c);
1635  break;
1636  case OCC_TYPE_LOCAL:
1637  peer2 = GST_peer_list[occ->other_peer_id];
1638  peer2->reference_cnt++;
1640  &occ->other_peer_identity);
1641  GNUNET_asprintf (&occ->emsg,
1642  "0x%llx: Timeout while connecting to CORE of peer with "
1643  "id: %u",
1644  (unsigned long long) occ->op_id,
1645  occ->peer->id);
1646  LOG_DEBUG ("Peer %u has PID %s\n",
1647  occ->other_peer_id,
1649  {
1650  struct GNUNET_PeerIdentity lpid;
1651 
1652  GNUNET_TESTING_peer_get_identity (peer->details.local.peer,
1653  &lpid);
1654  LOG_DEBUG ("Peer %u has PID %s\n",
1655  p1,
1656  GNUNET_i2s (&lpid));
1657  }
1658  occ->cgh_ch =
1660  occ->peer->details.local.cfg,
1663  &occ->other_peer_identity,
1664  &overlay_connect_notify, occ);
1665  break;
1666  }
1668 }
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.
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.
#define LOG(kind,...)
Redefine LOG with a changed log component string.
@ GNUNET_ERROR_TYPE_WARNING
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2330
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2249
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:1359
The identity of the host (wraps the signing key of the peer).
Handle to a client that is connected to a service.
Definition: service.c:252
A connected controller which is not our child.
struct Peer::@57::@59 remote

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_i2s(), 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::local, LOG, LOG_DEBUG, msg, RemotePeer2Context::ncn, occ_cache_get_handle_core_cb(), OCC_TYPE_LOCAL, OCC_TYPE_REMOTE_LATERAL, OCC_TYPE_REMOTE_SLAVE, occq_head, occq_tail, OverlayConnectContext::op_id, OverlayConnectContext::other_peer_id, OverlayConnectContext::other_peer_identity, overlay_connect_notify(), p2_controller_connect_cb(), RemotePeer2Context::p2c, OverlayConnectContext::p2ctx, RemotePeer2Context::p2n, OverlayConnectContext::peer, peer, Peer::reference_cnt, Peer::remote, OverlayConnectContext::remote, timeout_overlay_connect(), OverlayConnectContext::timeout_task, OverlayConnectContext::type, VALID_HOST_ID, and VALID_PEER_ID.

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 1678 of file gnunet-service-testbed_oc.c.

1679 {
1680  LOG_DEBUG ("0x%llx: Cleaning up rocc\n",
1681  (unsigned long long) rocc->op_id);
1682  if (NULL != rocc->attempt_connect_task_id)
1684  if (NULL != rocc->timeout_rocc_task_id)
1686  if (NULL != rocc->ohh)
1688  if (NULL != rocc->tcc.csh)
1692  GNUNET_assert (rocc->peer->reference_cnt > 0);
1693  rocc->peer->reference_cnt--;
1694  if ((GNUNET_YES == rocc->peer->destroy_flag) &&
1695  (0 == rocc->peer->reference_cnt))
1696  GST_destroy_peer (rocc->peer);
1697  GNUNET_free (rocc->hello);
1699  roccq_tail,
1700  rocc);
1701  GNUNET_free (rocc);
1702 }
static struct RemoteOverlayConnectCtx * roccq_tail
DLL tail for RequectOverlayConnectContext 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,...
struct GNUNET_SCHEDULER_Task * attempt_connect_task_id
Task for offering HELLO of A to B and doing try_connect.
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
The handle for offering HELLO.
struct GNUNET_SCHEDULER_Task * timeout_rocc_task_id
Task to timeout RequestOverlayConnect.
struct Peer * peer
The peer handle of peer B.
uint64_t op_id
The id of the operation responsible for creating this context.
struct GNUNET_MessageHeader * hello
Peer A's HELLO.

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_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, roccq_head, roccq_tail, 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().

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 1711 of file gnunet-service-testbed_oc.c.

1712 {
1713  struct RemoteOverlayConnectCtx *rocc = cls;
1714 
1715  GNUNET_assert (rocc->timeout_rocc_task_id != NULL);
1716  rocc->timeout_rocc_task_id = NULL;
1717  LOG_DEBUG ("0x%llx: rocc timed out\n",
1718  (unsigned long long) rocc->op_id);
1719  cleanup_rocc (rocc);
1720 }
static void cleanup_rocc(struct RemoteOverlayConnectCtx *rocc)
Function to cleanup RemoteOverlayConnectCtx and any associated tasks with it.

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().

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 1731 of file gnunet-service-testbed_oc.c.

1733 {
1734  struct RemoteOverlayConnectCtx *rocc = cls;
1735 
1736  LOG_DEBUG ("0x%llx: Request Overlay connect notify\n",
1737  (unsigned long long) rocc->op_id);
1738  GNUNET_assert (0 ==
1739  memcmp (new_peer, &rocc->a_id,
1740  sizeof(struct GNUNET_PeerIdentity)));
1741  LOG_DEBUG ("0x%llx: Peer %s connected\n",
1742  (unsigned long long) rocc->op_id,
1743  GNUNET_i2s (&rocc->a_id));
1744  cleanup_rocc (rocc);
1745 }

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

Referenced by handle_remote_overlay_connect().

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 1792 of file gnunet-service-testbed_oc.c.

1793 {
1794  struct RemoteOverlayConnectCtx *rocc = cls;
1795 
1796  GNUNET_assert (NULL != rocc->attempt_connect_task_id);
1797  rocc->attempt_connect_task_id = NULL;
1798  LOG_DEBUG ("0x%llx: Offering HELLO of peer %s to remote peer with id: %u\n",
1799  (unsigned long long) rocc->op_id,
1800  GNUNET_i2s (&rocc->a_id),
1801  rocc->peer->id);
1802  rocc->ohh =
1804  rocc->hello,
1806  rocc);
1807  if (NULL == rocc->ohh)
1808  rocc->attempt_connect_task_id =
1811  100
1814  &attempt_connect_task, rocc);
1815 }
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...
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...

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 rocc_cache_get_handle_transport_cb().

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 1766 of file gnunet-service-testbed_oc.c.

1767 {
1768  struct RemoteOverlayConnectCtx *rocc = cls;
1769 
1770  rocc->ohh = NULL;
1771  GNUNET_assert (NULL == rocc->attempt_connect_task_id);
1772  LOG_DEBUG ("0x%llx: HELLO of peer %s delivered to local peer with id: %u\n",
1773  (unsigned long long) rocc->op_id,
1774  GNUNET_i2s (&rocc->a_id),
1775  rocc->peer->id);
1776  rocc->tcc.cgh_p2_ats =
1778  rocc->peer->details.local.cfg,
1781  rocc, NULL, NULL, NULL);
1782 }
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.

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().

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 1828 of file gnunet-service-testbed_oc.c.

1835 {
1836  struct RemoteOverlayConnectCtx *rocc = cls;
1837 
1838  if (NULL == th)
1839  {
1840  rocc->timeout_rocc_task_id =
1842  return;
1843  }
1844  rocc->tcc.th_ = th;
1845  rocc->tcc.cfg = cfg;
1846  if (NULL !=
1848  &rocc->a_id))
1849  {
1850  LOG_DEBUG ("0x%llx: Target peer %s already connected to local peer: %u\n",
1851  (unsigned long long) rocc->op_id,
1852  GNUNET_i2s (&rocc->a_id),
1853  rocc->peer->id);
1854  cleanup_rocc (rocc);
1855  return;
1856  }
1857  rocc->attempt_connect_task_id =
1859 }
static void timeout_rocc_task(void *cls)
Task to timeout rocc and cleanit up.
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.

References RemoteOverlayConnectCtx::a_id, attempt_connect_task(), RemoteOverlayConnectCtx::attempt_connect_task_id, cfg, 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().

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 1870 of file gnunet-service-testbed_oc.c.

1873 {
1874  uint32_t peer_id;
1875  uint16_t msize;
1876  uint16_t hsize;
1877 
1878  msize = ntohs (msg->header.size);
1879  if (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type))
1880  {
1881  GNUNET_break (0);
1882  return GNUNET_SYSERR;
1883  }
1884  hsize = ntohs (msg->hello->size);
1885  if ((sizeof(struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hsize) !=
1886  msize)
1887  {
1888  GNUNET_break (0);
1889  return GNUNET_SYSERR;
1890  }
1891  peer_id = ntohl (msg->peer);
1892  if ((peer_id >= GST_peer_list_size) ||
1893  (NULL == GST_peer_list[peer_id]))
1894  {
1895  GNUNET_break_op (0);
1896  return GNUNET_SYSERR;
1897  }
1898  return GNUNET_OK;
1899 }
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
unsigned int GST_peer_list_size
The size of the peer list.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.

References GNUNET_break, GNUNET_break_op, GNUNET_MESSAGE_TYPE_HELLO, GNUNET_OK, GNUNET_SYSERR, GST_peer_list, GST_peer_list_size, msg, peer_id, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

◆ 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 1909 of file gnunet-service-testbed_oc.c.

1912 {
1913  struct GNUNET_SERVICE_Client *client = cls;
1914  struct RemoteOverlayConnectCtx *rocc;
1915  struct Peer *peer;
1916  struct GNUNET_PeerIdentity pid;
1917  static char pid_str[16];
1918  uint32_t peer_id;
1919  uint16_t hsize;
1920 
1921  hsize = ntohs (msg->hello->size);
1922  peer_id = ntohl (msg->peer);
1924  if (GNUNET_YES == peer->is_remote)
1925  {
1926  struct GNUNET_MessageHeader *msg2;
1927 
1928  msg2 = GNUNET_copy_message (&msg->header);
1929  GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller,
1930  msg2);
1932  return;
1933  }
1934  rocc = GNUNET_new (struct RemoteOverlayConnectCtx);
1935  rocc->op_id = GNUNET_ntohll (msg->operation_id);
1937  roccq_tail,
1938  rocc);
1939  rocc->a_id = msg->peer_identity;
1940  GNUNET_TESTING_peer_get_identity (peer->details.local.peer,
1941  &pid);
1942  (void) GNUNET_strlcpy (pid_str,
1943  GNUNET_i2s (&pid),
1944  sizeof(pid_str));
1945  LOG_DEBUG (
1946  "0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n",
1947  (unsigned long long) rocc->op_id,
1948  pid_str,
1949  GNUNET_i2s (&rocc->a_id),
1950  hsize);
1951  rocc->peer = peer;
1952  rocc->peer->reference_cnt++;
1953  rocc->hello = GNUNET_malloc (hsize);
1954  GNUNET_memcpy (rocc->hello,
1955  msg->hello,
1956  hsize);
1957  rocc->tcc.cgh_p2_th =
1959  rocc->peer->details.local.cfg,
1962  rocc,
1963  &rocc->a_id,
1965  rocc);
1966  rocc->timeout_rocc_task_id =
1969  rocc);
1971 }
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.
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.
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.
Definition: strings.c:138

References RemoteOverlayConnectCtx::a_id, cache_transport_peer_connect_notify(), ConnectivitySuggestContext::cgh_p2_th, GNUNET_TESTBED_Peer::controller, 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, RemoteOverlayConnectCtx::hello, Peer::local, LOG_DEBUG, msg, RemoteOverlayConnectCtx::op_id, RemoteOverlayConnectCtx::peer, peer, peer_id, pid, Peer::reference_cnt, rocc_cache_get_handle_transport_cb(), roccq_head, roccq_tail, GNUNET_MessageHeader::size, RemoteOverlayConnectCtx::tcc, timeout_rocc_task(), and RemoteOverlayConnectCtx::timeout_rocc_task_id.

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 1978 of file gnunet-service-testbed_oc.c.

1979 {
1980  struct OverlayConnectContext *occ;
1981 
1982  while (NULL != (occ = occq_head))
1983  cleanup_occ (occ);
1984 }

References cleanup_occ(), and occq_head.

Referenced by handle_shutdown_peers(), and shutdown_task().

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 1991 of file gnunet-service-testbed_oc.c.

1992 {
1993  struct RemoteOverlayConnectCtx *rocc;
1994 
1995  while (NULL != (rocc = roccq_head))
1996  cleanup_rocc (rocc);
1997 }

References cleanup_rocc(), and roccq_head.

Referenced by handle_shutdown_peers(), and shutdown_task().

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 332 of file gnunet-service-testbed_oc.c.

Referenced by cleanup_occ(), GST_free_occq(), GST_notify_client_disconnect_oc(), and handle_overlay_connect().

◆ occq_tail

struct OverlayConnectContext* occq_tail
static

DLL tail for OverlayConnectContext DLL.

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

Referenced by cleanup_occ(), and handle_overlay_connect().

◆ roccq_head

struct RemoteOverlayConnectCtx* roccq_head
static

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

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

Referenced by cleanup_rocc(), GST_free_roccq(), and handle_remote_overlay_connect().

◆ roccq_tail

struct RemoteOverlayConnectCtx* roccq_tail
static

DLL tail for RequectOverlayConnectContext DLL.

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

Referenced by cleanup_rocc(), and handle_remote_overlay_connect().