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

TESTBED service components that deals with starting slave controllers and establishing lateral links between controllers. More...

#include "gnunet-service-testbed.h"
Include dependency graph for gnunet-service-testbed_links.c:

Go to the source code of this file.

Data Structures

struct  LCFContext
 Link controllers request forwarding context. More...
 
struct  NeighbourConnectNotification
 Notification context to be used to notify when connection to the neighbour's controller is opened. More...
 
struct  Neighbour
 A connected controller which is not our child. More...
 
struct  NeighbourConnectCtxt
 Context information for establishing a link to neighbour (Used is GST_handle_link_controllers() More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "testbed-links", __VA_ARGS__)
 Redefine LOG with a changed log component string. More...
 
#define EVENT_MASK   (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED)
 The event mask for the events we listen from sub-controllers. More...
 

Enumerations

enum  LCFContextState { INIT, DELEGATED_HOST_REGISTERED, SLAVE_HOST_REGISTERED, FINISHED }
 States of LCFContext. More...
 

Functions

static void slave_list_add (struct Slave *slave)
 Adds a slave to the slave array. More...
 
static int drop_client_entries (void *cls, const struct GNUNET_HashCode *key, void *value)
 Clean up all forwarded operation overlay context matching the client given in cls. More...
 
static void route_list_add (struct Route *route)
 Adds a route to the route list. More...
 
static void neighbour_list_add (struct Neighbour *n)
 Add a neighbour to the neighbour list. More...
 
void GST_route_list_clear ()
 Cleans up the route list. More...
 
static int reghost_free_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
 Iterator for freeing hash map entries in a slave's reghost_map. More...
 
static void kill_slave (struct Slave *slave)
 Kill a Slave object. More...
 
static void destroy_slave (struct Slave *slave)
 Destroy a Slave object. More...
 
void GST_slave_list_clear ()
 Cleans up the slave list. More...
 
struct RouteGST_find_dest_route (uint32_t host_id)
 Finds the route with directly connected host as destination through which the destination host can be reached. More...
 
static void send_controller_link_response (struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const struct GNUNET_CONFIGURATION_Handle *cfg, const char *emsg)
 Function to send a failure reponse for controller link operation. More...
 
static void lcf_proc_task (void *cls)
 The Link Controller forwarding task. More...
 
static void lcf_proc_cc (void *cls, const char *emsg)
 Completion callback for host registrations while forwarding Link Controller messages. More...
 
static void lcf_forwarded_operation_timeout (void *cls)
 Task to free resources when forwarded link controllers has been timedout. More...
 
static void slave_event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
 Callback for event from slave controllers. More...
 
static void slave_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status)
 Callback to signal successfull startup of the controller process. More...
 
static void trigger_notifications (struct Neighbour *n)
 Trigger notification task if there are notification requests currently waiting in the given neighbour. More...
 
static void neighbour_connect_notify_task (void *cls)
 Task to call the notification queued in the notifications list of the given neighbour. More...
 
static void opstart_neighbour_conn (void *cls)
 Callback to be called when the neighbour connect operation is started. More...
 
static void oprelease_neighbour_conn (void *cls)
 Callback to be called when the neighbour connect operation is released. More...
 
struct NeighbourConnectNotificationGST_neighbour_get_connection (struct Neighbour *n, GST_NeigbourConnectNotifyCallback cb, void *cb_cls)
 Try to open a connection to the given neigbour. More...
 
void GST_neighbour_get_connection_cancel (struct NeighbourConnectNotification *h)
 Cancel the request for opening a connection to the neighbour. More...
 
void GST_neighbour_release_connection (struct Neighbour *n)
 Release the connection to the neighbour. More...
 
static void cleanup_ncc (struct NeighbourConnectCtxt *ncc)
 Cleanup neighbour connect contexts. More...
 
void GST_neighbour_list_clean ()
 Cleans up the neighbour list. More...
 
struct NeighbourGST_get_neighbour (uint32_t id)
 Get a neighbour from the neighbour list. More...
 
void GST_free_nccq ()
 Function to cleanup the neighbour connect contexts. More...
 
static void timeout_neighbour_connect (void *cls)
 Task to be run upon timeout while attempting to connect to the neighbour. More...
 
static void neighbour_connect_cb (void *cls, struct GNUNET_TESTBED_Controller *c)
 Callback called when a connection to the neighbour is made. More...
 
struct NeighbourGST_create_neighbour (struct GNUNET_TESTBED_Host *host)
 Function to create a neigbour and add it into the neighbour list. More...
 
void handle_link_controllers (void *cls, const struct GNUNET_TESTBED_ControllerLinkRequest *msg)
 Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS message. More...
 
void GST_link_notify_disconnect (struct GNUNET_SERVICE_Client *client)
 Clean up client handle if we stored any via handle_link_controllers(), the given client disconnected. More...
 
void GST_free_lcf ()
 Cleans up the queue used for forwarding link controllers requests. More...
 

Variables

static struct Neighbour ** neighbour_list
 The neighbour list. More...
 
static unsigned int neighbour_list_size
 The size of the neighbour list. More...
 
struct NeighbourConnectCtxtncc_head
 DLL head for the list of neighbour connect contexts. More...
 
struct NeighbourConnectCtxtncc_tail
 DLL tail for the list of neighbour connect contexts. More...
 
struct Slave ** GST_slave_list
 A list of directly linked neighbours. More...
 
unsigned int GST_slave_list_size
 The size of directly linked neighbours list. More...
 
static struct Route ** route_list
 A list of routes. More...
 
static struct LCFContextlcf_head
 The LCF queue. More...
 
static struct LCFContextlcf_tail
 The tail for the LCF queue. More...
 
static struct GNUNET_SCHEDULER_Tasklcf_proc_task_id
 The lcf_task handle. More...
 
static unsigned int route_list_size
 The size of the route list. More...
 

Detailed Description

TESTBED service components that deals with starting slave controllers and establishing lateral links between controllers.

Author
Sree Harsha Totakura

Definition in file gnunet-service-testbed_links.c.

Macro Definition Documentation

◆ LOG

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

Redefine LOG with a changed log component string.

Definition at line 36 of file gnunet-service-testbed_links.c.

Referenced by handle_link_controllers(), lcf_forwarded_operation_timeout(), lcf_proc_cc(), and slave_status_cb().

◆ EVENT_MASK

#define EVENT_MASK   (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED)

The event mask for the events we listen from sub-controllers.

Definition at line 42 of file gnunet-service-testbed_links.c.

Referenced by opstart_neighbour_conn(), and slave_status_cb().

Enumeration Type Documentation

◆ LCFContextState

States of LCFContext.

Enumerator
INIT 

The Context has been initialized; Nothing has been done on it.

DELEGATED_HOST_REGISTERED 

Delegated host has been registered at the forwarding controller.

SLAVE_HOST_REGISTERED 

The slave host has been registred at the forwarding controller.

FINISHED 

The context has been finished (may have error)

Definition at line 48 of file gnunet-service-testbed_links.c.

49 {
53  INIT,
54 
59 
64 
68  FINISHED
69 };

Function Documentation

◆ slave_list_add()

static void slave_list_add ( struct Slave slave)
static

Adds a slave to the slave array.

Parameters
slavethe slave controller to add

Definition at line 321 of file gnunet-service-testbed_links.c.

References GNUNET_assert, GST_array_grow_large_enough, GST_slave_list_size, and Slave::host_id.

Referenced by handle_link_controllers().

322 {
323  if (slave->host_id >= GST_slave_list_size)
326  slave->host_id);
327  GNUNET_assert (NULL == GST_slave_list[slave->host_id]);
328  GST_slave_list[slave->host_id] = slave;
329 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GST_array_grow_large_enough(ptr, size, accommodate_size)
Similar to GNUNET_array_grow(); however instead of calling GNUNET_array_grow() several times we call ...
uint32_t host_id
The id of the host this controller is running on.
Here is the caller graph for this function:

◆ drop_client_entries()

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

Clean up all forwarded operation overlay context matching the client given in cls.

Parameters
clsa struct GNUNET_SERVICE_Client * to match
keyunused
valuethe struct RegisteredHostContext to search for cls
Returns
GNUNET_OK (continue iterating)

Definition at line 342 of file gnunet-service-testbed_links.c.

References LCFContext::client, ForwardedOverlayConnectContext::client, RegisteredHostContext::focc_dll_head, GNUNET_OK, GST_cleanup_focc(), ForwardedOverlayConnectContext::next, and value.

Referenced by GST_link_notify_disconnect().

345 {
346  struct GNUNET_SERVICE_Client *client = cls;
347  struct RegisteredHostContext *rhc = value;
348  struct ForwardedOverlayConnectContext *focc;
349  struct ForwardedOverlayConnectContext *foccn;
350 
351  for (focc = rhc->focc_dll_head; NULL != focc; focc = foccn)
352  {
353  foccn = focc->next;
354  if (focc->client == client)
355  GST_cleanup_focc (focc);
356  }
357  return GNUNET_OK;
358 }
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
This context information will be created for each host that is registered at slave controllers during...
struct GNUNET_SERVICE_Client * client
The client handle.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Handle to a client that is connected to a service.
Definition: service.c:250
void GST_cleanup_focc(struct ForwardedOverlayConnectContext *focc)
Cleans up ForwardedOverlayConnectContext.
static char * value
Value of the record to add/remove.
Context information to used during operations which forward the overlay connect message.
struct ForwardedOverlayConnectContext * next
next ForwardedOverlayConnectContext in the DLL
Here is the call graph for this function:
Here is the caller graph for this function:

◆ route_list_add()

static void route_list_add ( struct Route route)
static

Adds a route to the route list.

Parameters
routethe route to add

Definition at line 367 of file gnunet-service-testbed_links.c.

References Route::dest, GNUNET_assert, GST_array_grow_large_enough, and route_list_size.

Referenced by handle_link_controllers().

368 {
369  if (route->dest >= route_list_size)
371  GNUNET_assert (NULL == route_list[route->dest]);
372  route_list[route->dest] = route;
373 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GST_array_grow_large_enough(ptr, size, accommodate_size)
Similar to GNUNET_array_grow(); however instead of calling GNUNET_array_grow() several times we call ...
uint32_t dest
destination host
Here is the caller graph for this function:

◆ neighbour_list_add()

static void neighbour_list_add ( struct Neighbour n)
static

Add a neighbour to the neighbour list.

Grows the neighbour list automatically.

Parameters
nthe neighbour to add

Definition at line 383 of file gnunet-service-testbed_links.c.

References GNUNET_assert, GST_array_grow_large_enough, Neighbour::host_id, and neighbour_list_size.

Referenced by GST_create_neighbour().

384 {
385  if (n->host_id >= neighbour_list_size)
387  n->host_id);
388  GNUNET_assert (NULL == neighbour_list[n->host_id]);
389  neighbour_list[n->host_id] = n;
390 }
uint32_t host_id
The id of the host this controller is running on.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GST_array_grow_large_enough(ptr, size, accommodate_size)
Similar to GNUNET_array_grow(); however instead of calling GNUNET_array_grow() several times we call ...
Here is the caller graph for this function:

◆ GST_route_list_clear()

void GST_route_list_clear ( void  )

Cleans up the route list.

Definition at line 397 of file gnunet-service-testbed_links.c.

References GNUNET_free, GNUNET_free_non_null, id, and route_list_size.

Referenced by shutdown_task().

398 {
399  unsigned int id;
400 
401  for (id = 0; id < route_list_size; id++)
402  if (NULL != route_list[id])
403  GNUNET_free (route_list[id]);
405  route_list = NULL;
406 }
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ reghost_free_iterator()

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

Iterator for freeing hash map entries in a slave's reghost_map.

Parameters
clshandle to the slave
keycurrent key code
valuevalue in the hash map
Returns
GNUNET_YES if we should continue to iterate, GNUNET_NO if not.

Definition at line 419 of file gnunet-service-testbed_links.c.

References RegisteredHostContext::focc_dll_head, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_YES, GST_cleanup_focc(), Slave::reghost_map, and value.

Referenced by kill_slave().

422 {
423  struct Slave *slave = cls;
424  struct RegisteredHostContext *rhc = value;
425  struct ForwardedOverlayConnectContext *focc;
426 
429  value));
430  while (NULL != (focc = rhc->focc_dll_head))
431  GST_cleanup_focc (focc);
432  GNUNET_free (value);
433  return GNUNET_YES;
434 }
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
struct GNUNET_CONTAINER_MultiHashMap * reghost_map
Hashmap to hold Registered host contexts.
This context information will be created for each host that is registered at slave controllers during...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Structure representing a connected(directly-linked) controller.
void GST_cleanup_focc(struct ForwardedOverlayConnectContext *focc)
Cleans up ForwardedOverlayConnectContext.
static char * value
Value of the record to add/remove.
Context information to used during operations which forward the overlay connect message.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kill_slave()

static void kill_slave ( struct Slave slave)
static

Kill a Slave object.

Parameters
slavethe Slave object

Definition at line 443 of file gnunet-service-testbed_links.c.

References Slave::controller, Slave::controller_proc, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_SYSERR, GNUNET_TESTBED_cancel_registration(), GNUNET_TESTBED_controller_disconnect(), GNUNET_TESTBED_controller_kill_(), Slave::hr_dll_head, Slave::hr_dll_tail, LOG_DEBUG, reghost_free_iterator(), Slave::reghost_map, and Slave::rhandle.

Referenced by GST_slave_list_clear(), and slave_status_cb().

444 {
445  struct HostRegistration *hr_entry;
446 
447  while (NULL != (hr_entry = slave->hr_dll_head))
448  {
450  hr_entry);
451  GNUNET_free (hr_entry);
452  }
453  if (NULL != slave->rhandle)
458  slave));
460  if (NULL != slave->controller)
462  if (NULL != slave->controller_proc)
463  {
464  LOG_DEBUG ("Stopping a slave\n");
466  }
467 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_CONTAINER_MultiHashMap * reghost_map
Hashmap to hold Registered host contexts.
void GNUNET_TESTBED_cancel_registration(struct GNUNET_TESTBED_HostRegistrationHandle *handle)
Cancel the pending registration.
void GNUNET_TESTBED_controller_disconnect(struct GNUNET_TESTBED_Controller *c)
Stop the given controller (also will terminate all peers and controllers dependent on this controller...
Definition: testbed_api.c:1720
void GNUNET_TESTBED_controller_kill_(struct GNUNET_TESTBED_ControllerProc *cproc)
Sends termination signal to the controller&#39;s helper process.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_HostRegistrationHandle * rhandle
The current host registration handle.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
A DLL of host registrations to be made.
struct HostRegistration * hr_dll_tail
Tail of the host registration DLL.
struct HostRegistration * hr_dll_head
Head of the host registration DLL.
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_TESTBED_Controller * controller
The controller handle.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
#define LOG_DEBUG(...)
Debug logging shorthand.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy_slave()

static void destroy_slave ( struct Slave slave)
static

Destroy a Slave object.

Parameters
slavethe Slave object

Definition at line 476 of file gnunet-service-testbed_links.c.

References Slave::controller_proc, GNUNET_free, GNUNET_TESTBED_controller_destroy_(), Slave::host_id, and LOG_DEBUG.

Referenced by GST_slave_list_clear(), and slave_status_cb().

477 {
478  if (NULL != slave->controller_proc)
479  {
481  LOG_DEBUG ("Slave stopped\n");
482  }
483  GST_slave_list[slave->host_id] = NULL;
484  GNUNET_free (slave);
485 }
void GNUNET_TESTBED_controller_destroy_(struct GNUNET_TESTBED_ControllerProc *cproc)
Cleans-up the controller&#39;s helper process handle.
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.
uint32_t host_id
The id of the host this controller is running on.
#define LOG_DEBUG(...)
Debug logging shorthand.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_slave_list_clear()

void GST_slave_list_clear ( void  )

Cleans up the slave list.

Definition at line 492 of file gnunet-service-testbed_links.c.

References destroy_slave(), GNUNET_free_non_null, GST_slave_list_size, id, and kill_slave().

Referenced by shutdown_task().

493 {
494  struct Slave *slave;
495  unsigned int id;
496 
497  for (id = 0; id < GST_slave_list_size; id++)
498  {
499  slave = GST_slave_list[id];
500  if (NULL == slave)
501  continue;
502  kill_slave (slave);
503  }
504  for (id = 0; id < GST_slave_list_size; id++)
505  {
506  slave = GST_slave_list[id];
507  if (NULL == slave)
508  continue;
509  destroy_slave (slave);
510  }
512  GST_slave_list = NULL;
513 }
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Structure representing a connected(directly-linked) controller.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_find_dest_route()

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

Parameters
host_idthe id of the destination host
Returns
the route with directly connected destination host; NULL if no route is found

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

References GST_context, Context::host_id, route_list_size, and Route::thru.

Referenced by forward_overlay_connect(), handle_link_controllers(), and handle_peer_create().

526 {
527  struct Route *route;
528 
529  if (route_list_size <= host_id)
530  return NULL;
531  while (NULL != (route = route_list[host_id]))
532  {
533  if (route->thru == GST_context->host_id)
534  break;
535  host_id = route->thru;
536  }
537  return route;
538 }
uint32_t thru
The destination host is reachable thru.
uint32_t host_id
Our host id according to this context.
A routing entry.
struct Context * GST_context
The master context; generated with the first INIT message.
Here is the caller graph for this function:

◆ send_controller_link_response()

static void send_controller_link_response ( struct GNUNET_SERVICE_Client client,
uint64_t  operation_id,
const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  emsg 
)
static

Function to send a failure reponse for controller link operation.

Parameters
clientthe client to send the message to
operation_idthe operation ID of the controller link request
cfgthe configuration with which the delegated controller is started. Can be NULL if the delegated controller is not started but just linked to.
emsgset to an error message explaining why the controller link failed. Setting this to NULL signifies success. !This should be NULL if cfg is set!

Definition at line 554 of file gnunet-service-testbed_links.c.

References GNUNET_TESTBED_ControllerLinkResponse::config_size, env, GNUNET_assert, GNUNET_free, GNUNET_htonll(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_compress_cfg_(), GNUNET_YES, lcf_proc_task(), msg, GNUNET_TESTBED_ControllerLinkResponse::operation_id, and GNUNET_TESTBED_ControllerLinkResponse::success.

Referenced by lcf_forwarded_operation_timeout(), neighbour_connect_cb(), slave_event_cb(), slave_status_cb(), and timeout_neighbour_connect().

558 {
559  struct GNUNET_MQ_Envelope *env;
561  char *xconfig;
562  size_t config_size;
563  size_t xconfig_size;
564  uint16_t msize;
565 
566  GNUNET_assert ((NULL == cfg) || (NULL == emsg));
567  xconfig = NULL;
568  xconfig_size = 0;
569  config_size = 0;
570  msize = 0;
571  if (NULL != cfg)
572  {
573  xconfig = GNUNET_TESTBED_compress_cfg_ (cfg,
574  &config_size,
575  &xconfig_size);
576  msize += xconfig_size;
577  }
578  if (NULL != emsg)
579  msize += strlen (emsg);
580  env = GNUNET_MQ_msg_extra (msg,
581  msize,
583  if (NULL == emsg)
584  msg->success = htons (GNUNET_YES);
586  msg->config_size = htons ((uint16_t) config_size);
587  if (NULL != xconfig)
588  {
589  GNUNET_memcpy (&msg[1],
590  xconfig,
591  xconfig_size);
592  GNUNET_free (xconfig);
593  }
594  if (NULL != emsg)
595  GNUNET_memcpy (&msg[1],
596  emsg,
597  strlen (emsg));
599  env);
600 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint64_t operation_id
The id of the operation which created this message.
Definition: testbed.h:190
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2437
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Response message for ControllerLinkRequest message.
Definition: testbed.h:169
#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT
Message to signal the result of GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS request.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
char * GNUNET_TESTBED_compress_cfg_(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size, size_t *xsize)
Function to serialize and compress using zlib a configuration through a configuration handle...
Definition: testbed_api.c:1784
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
uint16_t success
Set to GNUNET_YES to signify SUCCESS; GNUNET_NO to signify failure.
Definition: testbed.h:185
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint16_t config_size
The size of the compressed configuration.
Definition: testbed.h:180
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lcf_proc_task()

static void lcf_proc_task ( void *  cls)
static

The Link Controller forwarding task.

Parameters
clsthe LCFContext

Definition at line 695 of file gnunet-service-testbed_links.c.

References Slave::controller, LCFContext::delegated_host_id, DELEGATED_HOST_REGISTERED, FINISHED, LCFContext::gateway, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_is_host_registered_(), GNUNET_TESTBED_operation_done(), GST_host_list, GST_queue_host_registration(), GST_timeout, INIT, LCFContext::is_subordinate, lcf_forwarded_operation_timeout(), lcf_proc_cc(), LCFContext::op, LCFContext::slave_host_id, SLAVE_HOST_REGISTERED, LCFContext::state, and LCFContext::timeout_task.

Referenced by handle_link_controllers(), lcf_forwarded_operation_timeout(), lcf_proc_cc(), send_controller_link_response(), and slave_event_cb().

696 {
697  struct LCFContext *lcf = cls;
698 
699  lcf_proc_task_id = NULL;
700  switch (lcf->state)
701  {
702  case INIT:
703  if (GNUNET_NO ==
705  [lcf->delegated_host_id],
706  lcf->gateway->controller))
707  {
710  }
711  else
712  {
715  }
716  break;
717 
719  if (GNUNET_NO ==
721  lcf->gateway->controller))
722  {
725  }
726  else
727  {
730  }
731  break;
732 
735  lcf->gateway->controller,
736  GST_host_list[lcf->
739  lcf->is_subordinate);
740  lcf->timeout_task =
743  lcf);
744  lcf->state = FINISHED;
745  break;
746 
747  case FINISHED:
748  if (NULL != lcf->op)
751  lcf_tail,
752  lcf);
753  GNUNET_free (lcf);
754  if (NULL != lcf_head)
756  lcf_head);
757  }
758 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Link controllers request forwarding context.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_controller_link(void *op_cls, struct GNUNET_TESTBED_Controller *master, struct GNUNET_TESTBED_Host *delegated_host, struct GNUNET_TESTBED_Host *slave_host, int is_subordinate)
Create a link from slave controller to delegated controller.
Definition: testbed_api.c:1831
int is_subordinate
should the slave controller start the delegated controller?
void GST_queue_host_registration(struct Slave *slave, GNUNET_TESTBED_HostRegistrationCompletion cb, void *cb_cls, struct GNUNET_TESTBED_Host *host)
Adds a host registration&#39;s request to a slave&#39;s registration queue.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_TESTBED_Operation * op
Handle for operations which are forwarded while linking controllers.
enum LCFContextState state
The state of this context.
struct Slave * gateway
The gateway which will pass the link message to delegated host.
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:1253
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:1280
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2044
uint32_t delegated_host_id
The delegated host.
int GNUNET_TESTBED_is_host_registered_(const struct GNUNET_TESTBED_Host *host, const struct GNUNET_TESTBED_Controller *const controller)
Checks whether a host has been registered.
uint32_t slave_host_id
The slave host.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
struct GNUNET_SCHEDULER_Task * timeout_task
The timeout task.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lcf_proc_cc()

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

Completion callback for host registrations while forwarding Link Controller messages.

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

Definition at line 619 of file gnunet-service-testbed_links.c.

References DELEGATED_HOST_REGISTERED, FINISHED, GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_SCHEDULER_add_now(), INIT, lcf_proc_task(), LOG, SLAVE_HOST_REGISTERED, and LCFContext::state.

Referenced by lcf_proc_task().

621 {
622  struct LCFContext *lcf = cls;
623 
625  switch (lcf->state)
626  {
627  case INIT:
628  if (NULL != emsg)
629  goto registration_error;
632  break;
633 
635  if (NULL != emsg)
636  goto registration_error;
639  break;
640 
641  default:
642  GNUNET_assert (0); /* Shouldn't reach here */
643  }
644  return;
645 
646 registration_error:
648  "Host registration failed with message: %s\n",
649  emsg);
650  lcf->state = FINISHED;
652  lcf);
653 }
Link controllers request forwarding context.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum LCFContextState state
The state of this context.
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:1280
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lcf_forwarded_operation_timeout()

static void lcf_forwarded_operation_timeout ( void *  cls)
static

Task to free resources when forwarded link controllers has been timedout.

Parameters
clsthe LCFContext

Definition at line 671 of file gnunet-service-testbed_links.c.

References LCFContext::client, GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_SCHEDULER_add_now(), lcf_proc_task(), LOG, LCFContext::operation_id, send_controller_link_response(), and LCFContext::timeout_task.

Referenced by lcf_proc_task().

672 {
673  struct LCFContext *lcf = cls;
674 
675  lcf->timeout_task = NULL;
676  // GST_forwarded_operation_timeout (lcf->fopc, tc);
678  "A forwarded controller link operation has timed out\n");
680  lcf->operation_id,
681  NULL,
682  "A forwarded controller link operation has timed out\n");
685  lcf);
686 }
uint64_t operation_id
The id of the operation which created this context.
Link controllers request forwarding context.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SERVICE_Client * client
The client which has asked to perform this operation.
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:1280
struct GNUNET_SCHEDULER_Task * timeout_task
The timeout task.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ slave_event_cb()

static void slave_event_cb ( void *  cls,
const struct GNUNET_TESTBED_EventInformation event 
)
static

Callback for event from slave controllers.

Parameters
clsNULL
eventinformation about the event

Definition at line 768 of file gnunet-service-testbed_links.c.

References LCFContext::client, LCFContext::delegated_host_id, GNUNET_TESTBED_EventInformation::details, FINISHED, GNUNET_assert, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_ET_OPERATION_FINISHED, GNUNET_TESTBED_host_get_cfg_(), GNUNET_TESTBED_operation_done(), GST_host_list, lcf_proc_task(), LCFContext::op, GNUNET_TESTBED_EventInformation::op, GNUNET_TESTBED_EventInformation::operation_finished, LCFContext::operation_id, send_controller_link_response(), LCFContext::state, LCFContext::timeout_task, and GNUNET_TESTBED_EventInformation::type.

Referenced by opstart_neighbour_conn(), and slave_status_cb().

769 {
770  struct LCFContext *lcf;
771 
772  /* We currently only get here when working on LCFContexts */
774  lcf = event->op_cls;
775  GNUNET_assert (lcf->op == event->op);
777  lcf->op = NULL;
778  GNUNET_assert (FINISHED == lcf->state);
779  GNUNET_assert (NULL != lcf->timeout_task);
781  if (NULL == event->details.operation_finished.emsg)
785  NULL);
786  else
788  NULL,
789  event->details.operation_finished.emsg);
792  return;
793 }
uint64_t operation_id
The id of the operation which created this context.
Link controllers request forwarding context.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_EventInformation::@55::@60 operation_finished
Details about an operation finished event.
enum GNUNET_TESTBED_EventType type
Type of the event.
struct GNUNET_TESTBED_Operation * op
Handle for operations which are forwarded while linking controllers.
enum LCFContextState state
The state of this context.
struct GNUNET_SERVICE_Client * client
The client which has asked to perform this operation.
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:1280
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
A requested testbed operation has been completed.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2044
uint32_t delegated_host_id
The delegated host.
const struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_host_get_cfg_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s configuration template.
union GNUNET_TESTBED_EventInformation::@55 details
Details about the event.
struct GNUNET_SCHEDULER_Task * timeout_task
The timeout task.
struct GNUNET_TESTBED_Operation * op
Handle for the corresponding operation that generated this event.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ slave_status_cb()

static void slave_status_cb ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
int  status 
)
static

Callback to signal successfull startup of the controller process.

Parameters
clsthe handle to the slave whose status is to be found here
cfgthe configuration with which the controller has been started; NULL if status is not GNUNET_OK
statusGNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, GNUNET_TESTBED_controller_stop() shouldn't be called in this case

Definition at line 806 of file gnunet-service-testbed_links.c.

References LinkControllersContext::client, Slave::controller, Slave::controller_proc, destroy_slave(), EVENT_MASK, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_client_continue(), GNUNET_SYSERR, GNUNET_TESTBED_controller_connect(), GST_free_lcf(), GST_host_list, Slave::host_id, kill_slave(), Slave::lcc, LOG, LinkControllersContext::operation_id, send_controller_link_response(), slave_event_cb(), and trigger_notifications().

Referenced by handle_link_controllers().

809 {
810  struct Slave *slave = cls;
811  struct LinkControllersContext *lcc;
812 
813  lcc = slave->lcc;
814  if (GNUNET_SYSERR == status)
815  {
816  slave->controller_proc = NULL;
817  /* Stop all link controller forwarding tasks since we shutdown here anyway
818  and as these tasks they depend on the operation queues which are created
819  through GNUNET_TESTBED_controller_connect() and in kill_slave() we call
820  the destructor function GNUNET_TESTBED_controller_disconnect() */
821  GST_free_lcf ();
822  kill_slave (slave);
823  destroy_slave (slave);
824  slave = NULL;
825  LOG (GNUNET_ERROR_TYPE_WARNING, "Unexpected slave shutdown\n");
826  GNUNET_SCHEDULER_shutdown (); /* We too shutdown */
827  goto clean_lcc;
828  }
829  slave->controller =
832  slave);
833  if (NULL != slave->controller)
834  {
835  send_controller_link_response (lcc->client, lcc->operation_id, cfg, NULL);
836  }
837  else
838  {
840  "Could not connect to delegated controller");
841  kill_slave (slave);
842  destroy_slave (slave);
843  slave = NULL;
844  }
845 
846 clean_lcc:
847  if (NULL != lcc)
848  {
849  if (NULL != lcc->client)
850  {
852  lcc->client = NULL;
853  }
854  GNUNET_free (lcc);
855  }
856  if (NULL != slave)
857  slave->lcc = NULL;
858 }
Structure representing a connected(directly-linked) controller.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
Context information used while linking controllers.
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
uint16_t status
See PRISM_STATUS_*-constants.
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
uint64_t operation_id
The ID of the operation.
struct LinkControllersContext * lcc
handle to lcc which is associated with this slave startup.
struct GNUNET_TESTBED_Controller * GNUNET_TESTBED_controller_connect(struct GNUNET_TESTBED_Host *host, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls)
Connect to a controller process.
Definition: testbed_api.c:1554
uint32_t host_id
The id of the host this controller is running on.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_SERVICE_Client * client
The client which initiated the link controller operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ trigger_notifications()

static void trigger_notifications ( struct Neighbour n)
static

Trigger notification task if there are notification requests currently waiting in the given neighbour.

Also activates the neighbour connect operation if it was previously inactivated so that the connection to the neighbour can be re-used

Parameters
nthe neighbour

Definition at line 905 of file gnunet-service-testbed_links.c.

References Neighbour::conn_op, Neighbour::controller, GNUNET_assert, GNUNET_SCHEDULER_add_now(), GNUNET_TESTBED_operation_activate_(), Neighbour::inactive, neighbour_connect_notify_task(), Neighbour::nl_head, Neighbour::notify_task, and Neighbour::reference_cnt.

Referenced by GST_neighbour_get_connection(), GST_neighbour_get_connection_cancel(), neighbour_connect_notify_task(), opstart_neighbour_conn(), and slave_status_cb().

906 {
907  GNUNET_assert (NULL != n->conn_op);
908  if (NULL == n->nl_head)
909  return;
910  if (NULL == n->controller)
911  return;
912  if (NULL != n->notify_task)
913  return;
914  if (1 == n->inactive)
915  {
916  GNUNET_assert (0 == n->reference_cnt);
918  n->inactive = 0;
919  }
920  n->reference_cnt++;
921  n->notify_task =
923 }
unsigned int inactive
Is the conn_op inactivated?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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:1280
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct GNUNET_TESTBED_Operation * conn_op
Operation handle for opening a lateral connection to another controller.
void GNUNET_TESTBED_operation_activate_(struct GNUNET_TESTBED_Operation *op)
Marks and inactive operation as active.
unsigned int reference_cnt
How many references are present currently to this neighbour&#39;s connection.
struct NeighbourConnectNotification * nl_head
DLL head for the list of notification requests.
struct GNUNET_SCHEDULER_Task * notify_task
Task id for the task to call notifications from the notification list.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ neighbour_connect_notify_task()

static void neighbour_connect_notify_task ( void *  cls)
static

Task to call the notification queued in the notifications list of the given neighbour.

Parameters
clsthe neighbour

Definition at line 880 of file gnunet-service-testbed_links.c.

References NeighbourConnectNotification::cb, NeighbourConnectNotification::cb_cls, Neighbour::controller, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, h, Neighbour::nl_head, Neighbour::nl_tail, Neighbour::notify_task, and trigger_notifications().

Referenced by trigger_notifications().

881 {
882  struct Neighbour *n = cls;
884 
885  GNUNET_assert (NULL != (h = n->nl_head));
886  GNUNET_assert (NULL != n->notify_task);
887  n->notify_task = NULL;
888  GNUNET_assert (NULL != n->controller);
891  h->cb (h->cb_cls, n->controller);
892  GNUNET_free (h);
893 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
A connected controller which is not our child.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Notification context to be used to notify when connection to the neighbour&#39;s controller is opened...
struct NeighbourConnectNotification * nl_tail
DLL tail for the list of notification requests.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
GST_NeigbourConnectNotifyCallback cb
The notification callback to call when we are connect to neighbour.
void * cb_cls
The closure for the above callback.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct NeighbourConnectNotification * nl_head
DLL head for the list of notification requests.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_SCHEDULER_Task * notify_task
Task id for the task to call notifications from the notification list.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ opstart_neighbour_conn()

static void opstart_neighbour_conn ( void *  cls)
static

Callback to be called when the neighbour connect operation is started.

The connection to the neigbour is opened here and any pending notifications are trigger.

Parameters
clsthe neighbour

Definition at line 934 of file gnunet-service-testbed_links.c.

References Neighbour::conn_op, Neighbour::controller, EVENT_MASK, GNUNET_assert, GNUNET_TESTBED_controller_connect(), GST_host_list, Neighbour::host_id, LOG_DEBUG, slave_event_cb(), and trigger_notifications().

Referenced by GST_neighbour_get_connection().

935 {
936  struct Neighbour *n = cls;
937 
938  GNUNET_assert (NULL != n->conn_op);
939  GNUNET_assert (NULL == n->controller);
940  LOG_DEBUG ("Opening connection to controller on host %u\n", n->host_id);
942  EVENT_MASK,
944  NULL);
946 }
A connected controller which is not our child.
uint32_t host_id
The id of the host this controller is running on.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct GNUNET_TESTBED_Operation * conn_op
Operation handle for opening a lateral connection to another controller.
struct GNUNET_TESTBED_Controller * GNUNET_TESTBED_controller_connect(struct GNUNET_TESTBED_Host *host, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls)
Connect to a controller process.
Definition: testbed_api.c:1554
#define LOG_DEBUG(...)
Debug logging shorthand.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ oprelease_neighbour_conn()

static void oprelease_neighbour_conn ( void *  cls)
static

Callback to be called when the neighbour connect operation is released.

Parameters
clsthe neighbour

Definition at line 955 of file gnunet-service-testbed_links.c.

References Neighbour::conn_op, Neighbour::controller, GNUNET_assert, GNUNET_TESTBED_controller_disconnect(), Neighbour::host_id, Neighbour::inactive, LOG_DEBUG, Neighbour::nl_head, Neighbour::notify_task, and Neighbour::reference_cnt.

Referenced by GST_neighbour_get_connection().

956 {
957  struct Neighbour *n = cls;
958 
959  GNUNET_assert (0 == n->reference_cnt);
960  GNUNET_assert (NULL == n->notify_task);
961  GNUNET_assert (NULL == n->nl_head);
962  if (NULL != n->controller)
963  {
964  LOG_DEBUG ("Closing connection to controller on host %u\n", n->host_id);
966  n->controller = NULL;
967  }
968  n->conn_op = NULL;
969  n->inactive = 0;
970 }
A connected controller which is not our child.
uint32_t host_id
The id of the host this controller is running on.
void GNUNET_TESTBED_controller_disconnect(struct GNUNET_TESTBED_Controller *c)
Stop the given controller (also will terminate all peers and controllers dependent on this controller...
Definition: testbed_api.c:1720
unsigned int inactive
Is the conn_op inactivated?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct GNUNET_TESTBED_Operation * conn_op
Operation handle for opening a lateral connection to another controller.
unsigned int reference_cnt
How many references are present currently to this neighbour&#39;s connection.
struct NeighbourConnectNotification * nl_head
DLL head for the list of notification requests.
#define LOG_DEBUG(...)
Debug logging shorthand.
struct GNUNET_SCHEDULER_Task * notify_task
Task id for the task to call notifications from the notification list.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_neighbour_get_connection()

struct NeighbourConnectNotification* GST_neighbour_get_connection ( struct Neighbour n,
GST_NeigbourConnectNotifyCallback  cb,
void *  cb_cls 
)

Try to open a connection to the given neigbour.

If the connection is open already, then it is re-used. If not, the request is queued in the operation queues responsible for bounding the total number of file descriptors. The actual connection will happen when the operation queue marks the corresponding operation as active.

Parameters
nthe neighbour to open a connection to
cbthe notification callback to call when the connection is opened
cb_clsthe closure for the above callback

Definition at line 985 of file gnunet-service-testbed_links.c.

References NeighbourConnectNotification::cb, NeighbourConnectNotification::cb_cls, Neighbour::conn_op, Neighbour::controller, GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_new, GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), GST_opq_openfds, h, Neighbour::host_id, LOG_DEBUG, NeighbourConnectNotification::n, Neighbour::nl_head, Neighbour::nl_tail, oprelease_neighbour_conn(), opstart_neighbour_conn(), and trigger_notifications().

Referenced by handle_link_controllers(), and handle_overlay_connect().

988 {
990 
991  GNUNET_assert (NULL != cb);
992  LOG_DEBUG ("Attempting to get connection to controller on host %u\n",
993  n->host_id);
995  h->n = n;
996  h->cb = cb;
997  h->cb_cls = cb_cls;
999  if (NULL == n->conn_op)
1000  {
1001  GNUNET_assert (NULL == n->controller);
1006  return h;
1007  }
1009  return h;
1010 }
uint32_t host_id
The id of the host this controller is running on.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Notification context to be used to notify when connection to the neighbour&#39;s controller is opened...
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
struct NeighbourConnectNotification * nl_tail
DLL tail for the list of notification requests.
struct OperationQueue * GST_opq_openfds
Operation queue for open file descriptors.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
GST_NeigbourConnectNotifyCallback cb
The notification callback to call when we are connect to neighbour.
void * cb_cls
The closure for the above callback.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct GNUNET_TESTBED_Operation * conn_op
Operation handle for opening a lateral connection to another controller.
struct Neighbour * n
The neighbour.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
struct NeighbourConnectNotification * nl_head
DLL head for the list of notification requests.
#define LOG_DEBUG(...)
Debug logging shorthand.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_neighbour_get_connection_cancel()

void GST_neighbour_get_connection_cancel ( struct NeighbourConnectNotification h)

Cancel the request for opening a connection to the neighbour.

Parameters
hthe notification handle

Definition at line 1019 of file gnunet-service-testbed_links.c.

References cleanup_task, Neighbour::conn_op, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_operation_inactivate_(), GNUNET_YES, Neighbour::inactive, NeighbourConnectNotification::n, Neighbour::nl_head, Neighbour::nl_tail, Neighbour::notify_task, Neighbour::reference_cnt, and trigger_notifications().

Referenced by cleanup_ncc(), and cleanup_occ_rp2c().

1020 {
1021  struct Neighbour *n;
1022  int cleanup_task;
1023 
1024  n = h->n;
1025  cleanup_task = (h == n->nl_head) ? GNUNET_YES : GNUNET_NO;
1027  GNUNET_free (h);
1028  if (GNUNET_NO == cleanup_task)
1029  return;
1030  if (NULL == n->notify_task)
1031  return;
1032  GNUNET_assert (0 < n->reference_cnt);
1033  n->reference_cnt--;
1035  n->notify_task = NULL;
1036  if (NULL == n->nl_head)
1037  {
1038  if ((0 == n->reference_cnt) && (0 == n->inactive))
1039  {
1040  n->inactive = 1;
1042  }
1043  return;
1044  }
1046 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
A connected controller which is not our child.
unsigned int inactive
Is the conn_op inactivated?
static struct GNUNET_SCHEDULER_Task * cleanup_task
Cleanup task.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct NeighbourConnectNotification * nl_tail
DLL tail for the list of notification requests.
struct GNUNET_TESTBED_Operation * conn_op
Operation handle for opening a lateral connection to another controller.
struct Neighbour * n
The neighbour.
unsigned int reference_cnt
How many references are present currently to this neighbour&#39;s connection.
struct NeighbourConnectNotification * nl_head
DLL head for the list of notification requests.
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_TESTBED_operation_inactivate_(struct GNUNET_TESTBED_Operation *op)
Marks an active operation as inactive - the operation will be kept in a ready-to-be-released state an...
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_SCHEDULER_Task * notify_task
Task id for the task to call notifications from the notification list.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_neighbour_release_connection()

void GST_neighbour_release_connection ( struct Neighbour n)

Release the connection to the neighbour.

The actual connection will be closed if connections to other neighbour are waiting (to maintain a bound on the total number of connections that are open).

Parameters
nthe neighbour whose connection can be closed

Definition at line 1057 of file gnunet-service-testbed_links.c.

References Neighbour::conn_op, GNUNET_assert, GNUNET_TESTBED_operation_inactivate_(), Neighbour::inactive, and Neighbour::reference_cnt.

Referenced by cleanup_occ_rp2c(), and neighbour_connect_cb().

1058 {
1059  GNUNET_assert (0 == n->inactive);
1060  GNUNET_assert (0 < n->reference_cnt);
1061  n->reference_cnt--;
1062  if (0 == n->reference_cnt)
1063  {
1064  n->inactive = 1;
1066  }
1067 }
unsigned int inactive
Is the conn_op inactivated?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Operation * conn_op
Operation handle for opening a lateral connection to another controller.
unsigned int reference_cnt
How many references are present currently to this neighbour&#39;s connection.
void GNUNET_TESTBED_operation_inactivate_(struct GNUNET_TESTBED_Operation *op)
Marks an active operation as inactive - the operation will be kept in a ready-to-be-released state an...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_ncc()

static void cleanup_ncc ( struct NeighbourConnectCtxt ncc)
static

Cleanup neighbour connect contexts.

Parameters
nccthe neighbour connect context to cleanup

Definition at line 1076 of file gnunet-service-testbed_links.c.

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), GST_neighbour_get_connection_cancel(), NeighbourConnectCtxt::nh, and NeighbourConnectCtxt::timeout_task.

Referenced by GST_free_nccq(), GST_link_notify_disconnect(), neighbour_connect_cb(), and timeout_neighbour_connect().

1077 {
1078  if (NULL != ncc->nh)
1080  if (NULL != ncc->timeout_task)
1083  ncc_tail,
1084  ncc);
1085  GNUNET_free (ncc);
1086 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run upon timeout.
struct NeighbourConnectNotification * nh
The notification handle associated with the neighbour&#39;s connection request.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_neighbour_list_clean()

void GST_neighbour_list_clean ( void  )

Cleans up the neighbour list.

Definition at line 1093 of file gnunet-service-testbed_links.c.

References Neighbour::conn_op, GNUNET_free, GNUNET_free_non_null, GNUNET_TESTBED_operation_release_(), id, and neighbour_list_size.

Referenced by shutdown_task().

1094 {
1095  struct Neighbour *n;
1096  unsigned int id;
1097 
1098  for (id = 0; id < neighbour_list_size; id++)
1099  {
1100  if (NULL == (n = neighbour_list[id]))
1101  continue;
1102  if (NULL != n->conn_op)
1104  GNUNET_free (n);
1105  neighbour_list[id] = NULL;
1106  }
1108 }
A connected controller which is not our child.
void GNUNET_TESTBED_operation_release_(struct GNUNET_TESTBED_Operation *op)
An operation is &#39;done&#39; (was cancelled or finished); remove it from the queues and release associated ...
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_TESTBED_Operation * conn_op
Operation handle for opening a lateral connection to another controller.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_get_neighbour()

struct Neighbour* GST_get_neighbour ( uint32_t  id)

Get a neighbour from the neighbour list.

Parameters
idthe index of the neighbour in the neighbour list
Returns
the Neighbour; NULL if the given index in invalid (index greater than the list size or neighbour at that index is NULL)

Definition at line 1119 of file gnunet-service-testbed_links.c.

References id, and neighbour_list_size.

Referenced by handle_overlay_connect().

1120 {
1121  if (neighbour_list_size <= id)
1122  return NULL;
1123  return neighbour_list[id];
1124 }
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
Here is the caller graph for this function:

◆ GST_free_nccq()

void GST_free_nccq ( void  )

Function to cleanup the neighbour connect contexts.

Definition at line 1131 of file gnunet-service-testbed_links.c.

References cleanup_ncc().

Referenced by shutdown_task().

1132 {
1133  while (NULL != ncc_head)
1135 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeout_neighbour_connect()

static void timeout_neighbour_connect ( void *  cls)
static

Task to be run upon timeout while attempting to connect to the neighbour.

Parameters
clsthe NeighbourConnectCtxt created in GST_handle_link_controllers()

Definition at line 1144 of file gnunet-service-testbed_links.c.

References cleanup_ncc(), NeighbourConnectCtxt::client, NeighbourConnectCtxt::op_id, send_controller_link_response(), and NeighbourConnectCtxt::timeout_task.

Referenced by handle_link_controllers().

1145 {
1146  struct NeighbourConnectCtxt *ncc = cls;
1147 
1148  ncc->timeout_task = NULL;
1150  ncc->op_id,
1151  NULL,
1152  "Could not connect to delegated controller");
1153  cleanup_ncc (ncc);
1154 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run upon timeout.
Context information for establishing a link to neighbour (Used is GST_handle_link_controllers() ...
uint64_t op_id
The id of the link-controllers operation responsible for creating this context.
struct GNUNET_SERVICE_Client * client
The client requesting the connection.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ neighbour_connect_cb()

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

Callback called when a connection to the neighbour is made.

Parameters
clsthe NeighbourConnectCtxt created in GST_handle_link_controllers()
cthe handle the neighbour's controller

Definition at line 1164 of file gnunet-service-testbed_links.c.

References cleanup_ncc(), NeighbourConnectCtxt::client, GNUNET_SCHEDULER_cancel(), GST_neighbour_release_connection(), NeighbourConnectCtxt::n, NeighbourConnectCtxt::nh, NeighbourConnectCtxt::op_id, send_controller_link_response(), and NeighbourConnectCtxt::timeout_task.

Referenced by handle_link_controllers().

1166 {
1167  struct NeighbourConnectCtxt *ncc = cls;
1168 
1170  ncc->timeout_task = NULL;
1171  ncc->nh = NULL;
1174  ncc->op_id,
1175  NULL,
1176  NULL);
1177  cleanup_ncc (ncc);
1178 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run upon timeout.
Context information for establishing a link to neighbour (Used is GST_handle_link_controllers() ...
struct Neighbour * n
The neighbour to whom connection should be made.
struct NeighbourConnectNotification * nh
The notification handle associated with the neighbour&#39;s connection request.
uint64_t op_id
The id of the link-controllers operation responsible for creating this context.
struct GNUNET_SERVICE_Client * client
The client requesting the connection.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_create_neighbour()

struct Neighbour* GST_create_neighbour ( struct GNUNET_TESTBED_Host host)

Function to create a neigbour and add it into the neighbour list.

Parameters
hostthe host of the neighbour

Definition at line 1187 of file gnunet-service-testbed_links.c.

References GNUNET_new, GNUNET_TESTBED_host_get_id_(), Neighbour::host_id, and neighbour_list_add().

Referenced by handle_link_controllers(), and handle_overlay_connect().

1188 {
1189  struct Neighbour *n;
1190 
1191  n = GNUNET_new (struct Neighbour);
1193  neighbour_list_add (n); /* just add; connect on-demand */
1194  return n;
1195 }
A connected controller which is not our child.
uint32_t host_id
The id of the host this controller is running on.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_link_controllers()

void handle_link_controllers ( void *  cls,
const struct GNUNET_TESTBED_ControllerLinkRequest msg 
)

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS message.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 1205 of file gnunet-service-testbed_links.c.

References LCFContext::client, LinkControllersContext::client, NeighbourConnectCtxt::client, Slave::controller_proc, LCFContext::delegated_host_id, GNUNET_TESTBED_ControllerLinkRequest::delegated_host_id, Route::dest, LCFContext::gateway, GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_WARNING, GNUNET_new, GNUNET_NO, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TESTBED_controller_start(), GST_context, GST_create_neighbour(), GST_find_dest_route(), GST_host_list, GST_host_list_size, GST_neighbour_get_connection(), GST_slave_list_size, GST_timeout, Slave::host_id, Context::host_id, INIT, LCFContext::is_subordinate, GNUNET_TESTBED_ControllerLinkRequest::is_subordinate, Slave::lcc, lcf_proc_task(), LOG, LOG_DEBUG, Context::master_ip, NeighbourConnectCtxt::n, neighbour_connect_cb(), neighbour_list_size, NeighbourConnectCtxt::nh, NeighbourConnectCtxt::op_id, LCFContext::operation_id, GNUNET_TESTBED_ControllerLinkRequest::operation_id, LinkControllersContext::operation_id, Slave::reghost_map, route_list_add(), route_list_size, LCFContext::slave_host_id, GNUNET_TESTBED_ControllerLinkRequest::slave_host_id, slave_list_add(), slave_status_cb(), LCFContext::state, Route::thru, timeout_neighbour_connect(), and NeighbourConnectCtxt::timeout_task.

1207 {
1208  struct GNUNET_SERVICE_Client *client = cls;
1209  struct LCFContext *lcf;
1210  struct Route *route;
1211  struct Route *new_route;
1212  uint64_t op_id;
1213  uint32_t delegated_host_id;
1214  uint32_t slave_host_id;
1215 
1216  if (NULL == GST_context)
1217  {
1218  GNUNET_break (0);
1219  GNUNET_SERVICE_client_drop (client);
1220  return;
1221  }
1222  delegated_host_id = ntohl (msg->delegated_host_id);
1223  if (delegated_host_id == GST_context->host_id)
1224  {
1225  GNUNET_break (0);
1227  "Trying to link ourselves\n");
1228  GNUNET_SERVICE_client_drop (client);
1229  return;
1230  }
1231  if ((delegated_host_id >= GST_host_list_size) ||
1232  (NULL == GST_host_list[delegated_host_id]))
1233  {
1235  "Delegated host %u not registered with us\n",
1236  delegated_host_id);
1237  GNUNET_SERVICE_client_drop (client);
1238  return;
1239  }
1240  slave_host_id = ntohl (msg->slave_host_id);
1241  if ((slave_host_id >= GST_host_list_size) ||
1242  (NULL == GST_host_list[slave_host_id]))
1243  {
1245  "Slave host %u not registered with us\n",
1246  slave_host_id);
1247  GNUNET_SERVICE_client_drop (client);
1248  return;
1249  }
1250  if (slave_host_id == delegated_host_id)
1251  {
1253  "Slave and delegated host are same\n");
1254  GNUNET_SERVICE_client_drop (client);
1255  return;
1256  }
1257  op_id = GNUNET_ntohll (msg->operation_id);
1258  if (slave_host_id == GST_context->host_id) /* Link from us */
1259  {
1260  struct Slave *slave;
1261  struct LinkControllersContext *lcc;
1262 
1263  if (1 != msg->is_subordinate)
1264  {
1265  struct Neighbour *n;
1266  struct NeighbourConnectCtxt *ncc;
1267 
1268  if ((delegated_host_id < neighbour_list_size) &&
1269  (NULL != neighbour_list[delegated_host_id]))
1270  {
1271  GNUNET_break (0);
1272  GNUNET_SERVICE_client_drop (client);
1273  return;
1274  }
1275  LOG_DEBUG ("Received request to establish a link to host %u\n",
1276  delegated_host_id);
1277  n = GST_create_neighbour (GST_host_list[delegated_host_id]);
1278  ncc = GNUNET_new (struct NeighbourConnectCtxt);
1279  ncc->n = n;
1280  ncc->op_id = op_id;
1281  ncc->client = client;
1282  ncc->nh = GST_neighbour_get_connection (n,
1284  ncc);
1285  ncc->timeout_task
1288  ncc);
1290  ncc_tail,
1291  ncc);
1293  return;
1294  }
1295  if ((delegated_host_id < GST_slave_list_size) &&
1296  (NULL != GST_slave_list[delegated_host_id]))
1297  {
1298  GNUNET_break (0);
1299  GNUNET_SERVICE_client_drop (client);
1300  return;
1301  }
1302  LOG_DEBUG ("Received request to start and establish a link to host %u\n",
1303  delegated_host_id);
1304  slave = GNUNET_new (struct Slave);
1305  slave->host_id = delegated_host_id;
1307  GNUNET_NO);
1308  slave_list_add (slave);
1309  lcc = GNUNET_new (struct LinkControllersContext);
1310  lcc->operation_id = op_id;
1311  lcc->client = client;
1312  slave->lcc = lcc;
1313  slave->controller_proc
1315  GST_host_list[slave->host_id],
1316  &slave_status_cb,
1317  slave);
1318  new_route = GNUNET_new (struct Route);
1319  new_route->dest = delegated_host_id;
1320  new_route->thru = GST_context->host_id;
1321  route_list_add (new_route);
1322  return;
1323  }
1324 
1325  /* Route the request */
1326  if (slave_host_id >= route_list_size)
1327  {
1329  "No route towards slave host");
1330  GNUNET_SERVICE_client_drop (client);
1331  return;
1332  }
1333  lcf = GNUNET_new (struct LCFContext);
1334  lcf->delegated_host_id = delegated_host_id;
1335  lcf->slave_host_id = slave_host_id;
1336  route = GST_find_dest_route (slave_host_id);
1337  GNUNET_assert (NULL != route); /* because we add routes carefully */
1339  GNUNET_assert (NULL != GST_slave_list[route->dest]);
1340  lcf->is_subordinate = msg->is_subordinate;
1341  lcf->state = INIT;
1342  lcf->operation_id = op_id;
1343  lcf->gateway = GST_slave_list[route->dest];
1344  lcf->client = client;
1345  if (NULL == lcf_head)
1346  {
1347  GNUNET_assert (NULL == lcf_proc_task_id);
1349  lcf_tail,
1350  lcf);
1352  lcf);
1353  }
1354  else
1355  {
1357  lcf_tail,
1358  lcf);
1359  }
1360  /* FIXME: Adding a new route should happen after the controllers are linked
1361  * successfully */
1362  if (1 != msg->is_subordinate)
1363  {
1365  return;
1366  }
1367  if ((delegated_host_id < route_list_size) &&
1368  (NULL != route_list[delegated_host_id]))
1369  {
1370  GNUNET_break_op (0); /* Are you trying to link delegated host twice
1371  * with is subordinate flag set to GNUNET_YES? */
1372  GNUNET_SERVICE_client_drop (client);
1373  return;
1374  }
1375  new_route = GNUNET_new (struct Route);
1376  new_route->dest = delegated_host_id;
1377  new_route->thru = route->dest;
1378  route_list_add (new_route);
1380 }
struct GNUNET_CONTAINER_MultiHashMap * reghost_map
Hashmap to hold Registered host contexts.
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run upon timeout.
A connected controller which is not our child.
uint64_t operation_id
The id of the operation which created this context.
Context information for establishing a link to neighbour (Used is GST_handle_link_controllers() ...
unsigned int GST_host_list_size
The size of the host list.
struct Neighbour * n
The neighbour to whom connection should be made.
Link controllers request forwarding context.
uint32_t thru
The destination host is reachable thru.
struct NeighbourConnectNotification * nh
The notification handle associated with the neighbour&#39;s connection request.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
char * master_ip
The network address of the master controller.
int is_subordinate
should the slave controller start the delegated controller?
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Structure representing a connected(directly-linked) controller.
enum LCFContextState state
The state of this context.
Context information used while linking controllers.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct Slave * gateway
The gateway which will pass the link message to delegated host.
Handle to a client that is connected to a service.
Definition: service.c:250
uint32_t delegated_host_id
For which host should requests be delegated? NBO.
Definition: testbed.h:146
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:1253
uint32_t host_id
Our host id according to this context.
struct GNUNET_SERVICE_Client * client
The client which has asked to perform this operation.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
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:1280
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
A routing entry.
uint32_t delegated_host_id
The delegated host.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.
uint64_t operation_id
The ID of the operation.
uint32_t slave_host_id
The slave host.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct LinkControllersContext * lcc
handle to lcc which is associated with this slave startup.
uint64_t op_id
The id of the link-controllers operation responsible for creating this context.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
uint32_t slave_host_id
Which host is responsible for managing the delegation? NBO.
Definition: testbed.h:156
uint32_t host_id
The id of the host this controller is running on.
struct Context * GST_context
The master context; generated with the first INIT message.
struct GNUNET_SERVICE_Client * client
The client requesting the connection.
uint8_t is_subordinate
Set to 1 if the receiving controller is the master controller for the slave host (and thus responsibl...
Definition: testbed.h:162
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
uint64_t operation_id
The id of the operation which created this message.
Definition: testbed.h:151
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
uint32_t dest
destination host
#define LOG_DEBUG(...)
Debug logging shorthand.
struct GNUNET_TESTBED_ControllerProc * GNUNET_TESTBED_controller_start(const char *trusted_ip, struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_ControllerStatusCallback cb, void *cls)
Starts a controller process at the given host.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
struct GNUNET_SERVICE_Client * client
The client which initiated the link controller operation.
Here is the call graph for this function:

◆ GST_link_notify_disconnect()

void GST_link_notify_disconnect ( struct GNUNET_SERVICE_Client client)

Clean up client handle if we stored any via handle_link_controllers(), the given client disconnected.

Parameters
clientthe client that is history

Definition at line 1390 of file gnunet-service-testbed_links.c.

References cleanup_ncc(), LCFContext::client, LinkControllersContext::client, NeighbourConnectCtxt::client, drop_client_entries(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_TESTBED_operation_done(), GST_slave_list_size, Slave::lcc, LCFContext::next, NeighbourConnectCtxt::next, LCFContext::op, and Slave::reghost_map.

Referenced by client_disconnect_cb().

1391 {
1392  struct NeighbourConnectCtxt *ncc;
1393  struct NeighbourConnectCtxt *nccn;
1394  struct LCFContext *lcf;
1395  struct LCFContext *lcfn;
1396 
1397  for (ncc = ncc_head; NULL != ncc; ncc = nccn)
1398  {
1399  nccn = ncc->next;
1400  if (ncc->client == client)
1401  cleanup_ncc (ncc);
1402  }
1403  for (unsigned int i = 0; i < GST_slave_list_size; i++)
1404  {
1405  struct Slave *slave = GST_slave_list[i];
1406  struct LinkControllersContext *lcc;
1407 
1408  if (NULL == slave)
1409  continue;
1412  client);
1413  lcc = slave->lcc;
1414  if (NULL == lcc)
1415  continue;
1416  if (lcc->client == client)
1417  {
1418  slave->lcc = NULL;
1419  GNUNET_free (lcc);
1420  }
1421  }
1422  for (lcf = lcf_head; NULL != lcf; lcf = lcfn)
1423  {
1424  lcfn = lcf->next;
1425  if ((NULL != lcf) &&
1426  (client == lcf->client))
1427  {
1428  if (NULL != lcf->op)
1431  lcf_tail,
1432  lcf);
1433  GNUNET_free (lcf);
1434  }
1435  }
1436 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_CONTAINER_MultiHashMap * reghost_map
Hashmap to hold Registered host contexts.
Context information for establishing a link to neighbour (Used is GST_handle_link_controllers() ...
Link controllers request forwarding context.
struct GNUNET_TESTBED_Operation * op
Handle for operations which are forwarded while linking controllers.
Structure representing a connected(directly-linked) controller.
Context information used while linking controllers.
struct GNUNET_SERVICE_Client * client
The client which has asked to perform this operation.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2044
struct LinkControllersContext * lcc
handle to lcc which is associated with this slave startup.
struct NeighbourConnectCtxt * next
DLL next for inclusion in the corresponding context list.
struct GNUNET_SERVICE_Client * client
The client requesting the connection.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct LCFContext * next
The LCFContext.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_SERVICE_Client * client
The client which initiated the link controller operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_free_lcf()

void GST_free_lcf ( void  )

Cleans up the queue used for forwarding link controllers requests.

Definition at line 1443 of file gnunet-service-testbed_links.c.

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_operation_done(), lcf_head, LCFContext::op, and LCFContext::timeout_task.

Referenced by shutdown_task(), and slave_status_cb().

1444 {
1445  struct LCFContext *lcf;
1446 
1447  if (NULL != lcf_head)
1448  {
1449  if (NULL != lcf_proc_task_id)
1450  {
1452  lcf_proc_task_id = NULL;
1453  }
1454  }
1455  GNUNET_assert (NULL == lcf_proc_task_id);
1456  for (lcf = lcf_head; NULL != lcf; lcf = lcf_head)
1457  {
1458  if (NULL != lcf->op)
1460  if (NULL != lcf->timeout_task)
1463  lcf_tail,
1464  lcf);
1465  GNUNET_free (lcf);
1466  }
1467 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Link controllers request forwarding context.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Operation * op
Handle for operations which are forwarded while linking controllers.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2044
struct GNUNET_SCHEDULER_Task * timeout_task
The timeout task.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ neighbour_list

struct Neighbour** neighbour_list
static

The neighbour list.

Definition at line 218 of file gnunet-service-testbed_links.c.

◆ neighbour_list_size

unsigned int neighbour_list_size
static

The size of the neighbour list.

Definition at line 223 of file gnunet-service-testbed_links.c.

Referenced by GST_get_neighbour(), GST_neighbour_list_clean(), handle_link_controllers(), and neighbour_list_add().

◆ ncc_head

struct NeighbourConnectCtxt* ncc_head

DLL head for the list of neighbour connect contexts.

Definition at line 272 of file gnunet-service-testbed_links.c.

◆ ncc_tail

struct NeighbourConnectCtxt* ncc_tail

DLL tail for the list of neighbour connect contexts.

Definition at line 277 of file gnunet-service-testbed_links.c.

◆ GST_slave_list

struct Slave** GST_slave_list

A list of directly linked neighbours.

Definition at line 282 of file gnunet-service-testbed_links.c.

Referenced by handle_barrier_init(), handle_peer_create(), handle_shutdown_peers(), and handle_slave_get_config().

◆ GST_slave_list_size

unsigned int GST_slave_list_size

◆ route_list

struct Route** route_list
static

A list of routes.

Definition at line 292 of file gnunet-service-testbed_links.c.

◆ lcf_head

struct LCFContext* lcf_head
static

The LCF queue.

Definition at line 297 of file gnunet-service-testbed_links.c.

Referenced by GST_free_lcf().

◆ lcf_tail

struct LCFContext* lcf_tail
static

The tail for the LCF queue.

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

◆ lcf_proc_task_id

struct GNUNET_SCHEDULER_Task* lcf_proc_task_id
static

The lcf_task handle.

Definition at line 307 of file gnunet-service-testbed_links.c.

◆ route_list_size

unsigned int route_list_size
static

The size of the route list.

Definition at line 312 of file gnunet-service-testbed_links.c.

Referenced by GST_find_dest_route(), GST_route_list_clear(), handle_link_controllers(), and route_list_add().