GNUnet  0.20.0
gnunet-service-testbed.h File Reference

data structures shared amongst components of TESTBED service More...

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

Go to the source code of this file.

Data Structures

struct  Route
 A routing entry. More...
 
struct  ForwardedOperationContext
 Context information for operations forwarded to subcontrollers. More...
 
struct  HostRegistration
 A DLL of host registrations to be made. More...
 
struct  LinkControllersContext
 Context information used while linking controllers. More...
 
struct  Peer
 A peer. More...
 
struct  Context
 Context to hold data of peer. More...
 
struct  SharedService
 The structure for identifying a shared service. More...
 
struct  ForwardedOverlayConnectContext
 Context information to used during operations which forward the overlay connect message. More...
 
struct  RegisteredHostContext
 This context information will be created for each host that is registered at slave controllers during overlay connects. More...
 
struct  HandlerContext_ShutdownPeers
 Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler. More...
 

Macros

#define LOG(kind, ...)    GNUNET_log (kind, __VA_ARGS__)
 Generic logging. More...
 
#define LOG_DEBUG(...)    LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 Debug logging. More...
 
#define LIST_GROW_STEP   10
 By how much should the arrays lists grow. More...
 
#define VALID_HOST_ID(id)    (((id) < GST_host_list_size) && (NULL != GST_host_list[id]))
 Condition to check if host id is valid. More...
 
#define VALID_PEER_ID(id)    (((id) < GST_peer_list_size) && (NULL != GST_peer_list[id]))
 Condition to check if peer id is valid. More...
 
#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 it only once. More...
 

Functions

void GST_destroy_peer (struct Peer *peer)
 Function to destroy a peer. More...
 
void GST_destroy_peers (void)
 Stops and destroys all peers. 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...
 
void handle_overlay_connect (void *cls, const struct GNUNET_TESTBED_OverlayConnectMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT messages. More...
 
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. More...
 
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. More...
 
void GST_forwarded_operation_timeout (void *cls)
 Task to free resources when forwarded operation has been timed out. More...
 
void GST_clear_fopcq (void)
 Clears the forwarded operations queue. More...
 
void GST_send_operation_fail_msg (struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
 Send operation failure message to client. More...
 
void GST_notify_client_disconnect_oc (struct GNUNET_SERVICE_Client *client)
 Notify OC subsystem that client disconnected. More...
 
void GST_notify_client_disconnect_peers (struct GNUNET_SERVICE_Client *client)
 Notify peers subsystem that client disconnected. More...
 
void GST_send_operation_success_msg (struct GNUNET_SERVICE_Client *client, uint64_t operation_id)
 Function to send generic operation success message to given client. 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...
 
int check_peer_create (void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
 Check #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages. More...
 
void handle_peer_create (void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
 Handler for #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages. More...
 
void handle_peer_destroy (void *cls, const struct GNUNET_TESTBED_PeerDestroyMessage *msg)
 Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages. More...
 
void handle_peer_start (void *cls, const struct GNUNET_TESTBED_PeerStartMessage *msg)
 Message handler for GNUNET_MESSAGE_TYPE_TESTBED_START_PEER messages. More...
 
void handle_peer_stop (void *cls, const struct GNUNET_TESTBED_PeerStopMessage *msg)
 Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages. More...
 
void handle_peer_get_config (void *cls, const struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg)
 Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG messages. More...
 
void handle_shutdown_peers (void *cls, const struct GNUNET_TESTBED_ShutdownPeersMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS messages. More...
 
int check_manage_peer_service (void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
 Check GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message. More...
 
void handle_manage_peer_service (void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE messages. More...
 
int check_peer_reconfigure (void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
 Check #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages. More...
 
void handle_peer_reconfigure (void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
 Handler for #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages. More...
 
void GST_free_mctxq (void)
 Frees the ManageServiceContext queue. More...
 
void GST_free_lcf (void)
 Cleans up the queue used for forwarding link controllers requests. More...
 
void GST_route_list_clear (void)
 Cleans up the route list. More...
 
void GST_process_next_focc (struct RegisteredHostContext *rhc)
 Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext. More...
 
void GST_cleanup_focc (struct ForwardedOverlayConnectContext *focc)
 Cleans up ForwardedOverlayConnectContext. More...
 
void GST_free_occq (void)
 Clears all pending overlay connect contexts in queue. More...
 
void GST_free_roccq (void)
 Clears all pending remote overlay connect contexts in queue. More...
 
void GST_free_prcq (void)
 Cleans up the Peer reconfigure context list. More...
 
void GST_cache_init (unsigned int size)
 Initializes the cache. More...
 
void GST_cache_clear (void)
 Clear cache. More...
 
const struct GNUNET_MessageHeaderGST_cache_lookup_hello (const unsigned int peer_id)
 Looks up in the hello cache and returns the HELLO of the given peer. More...
 
void GST_cache_add_hello (const unsigned int peer_id, const struct GNUNET_MessageHeader *hello)
 Caches the HELLO of the given peer. More...
 
void GST_stats_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize logging CPU and IO statisticfs. More...
 
void GST_stats_destroy (void)
 Shutdown the status calls module. More...
 

Variables

struct GNUNET_CONFIGURATION_HandleGST_config
 Our configuration. More...
 
struct ContextGST_context
 The master context; generated with the first INIT message. More...
 
struct ForwardedOperationContextfopcq_head
 DLL head for forwarded operation contexts. More...
 
struct ForwardedOperationContextfopcq_tail
 DLL tail for forwarded operation contexts. More...
 
struct Peer ** GST_peer_list
 A list of peers we know about. More...
 
struct GNUNET_TESTBED_Host ** GST_host_list
 Array of hosts. More...
 
struct OperationQueueGST_opq_openfds
 Operation queue for open file descriptors. More...
 
struct GNUNET_TIME_Relative GST_timeout
 Timeout for operations which may take some time. More...
 
unsigned int GST_peer_list_size
 The size of the peer list. More...
 
unsigned int GST_num_local_peers
 The current number of peers running locally under this controller. More...
 
unsigned int GST_host_list_size
 The size of the host list. More...
 
char * GST_stats_dir
 The directory where to store load statistics data. More...
 

Detailed Description

data structures shared amongst components of TESTBED service

Author
Sree Harsha Totakura

Definition in file gnunet-service-testbed.h.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)     GNUNET_log (kind, __VA_ARGS__)

Generic logging.

Definition at line 44 of file gnunet-service-testbed.h.

◆ LOG_DEBUG

#define LOG_DEBUG (   ...)     LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)

Debug logging.

Definition at line 50 of file gnunet-service-testbed.h.

◆ LIST_GROW_STEP

#define LIST_GROW_STEP   10

By how much should the arrays lists grow.

Definition at line 56 of file gnunet-service-testbed.h.

◆ VALID_HOST_ID

#define VALID_HOST_ID (   id)     (((id) < GST_host_list_size) && (NULL != GST_host_list[id]))

Condition to check if host id is valid.

Definition at line 473 of file gnunet-service-testbed.h.

◆ VALID_PEER_ID

#define VALID_PEER_ID (   id)     (((id) < GST_peer_list_size) && (NULL != GST_peer_list[id]))

Condition to check if peer id is valid.

Definition at line 479 of file gnunet-service-testbed.h.

◆ GST_array_grow_large_enough

#define GST_array_grow_large_enough (   ptr,
  size,
  accommodate_size 
)
Value:
do \
{ \
unsigned int growth_size; \
GNUNET_assert (size <= accommodate_size); \
growth_size = size; \
while (growth_size <= accommodate_size) \
growth_size += LIST_GROW_STEP; \
GNUNET_array_grow (ptr, size, growth_size); \
GNUNET_assert (size > accommodate_size); \
} while (0)
#define LIST_GROW_STEP
By how much should the arrays lists grow.
static unsigned int size
Size of the "table".
Definition: peer.c:68

Similar to GNUNET_array_grow(); however instead of calling GNUNET_array_grow() several times we call it only once.

The array is also made to grow in steps of LIST_GROW_STEP.

Parameters
ptrthe array pointer to grow
sizethe size of array
accommodate_sizethe size which the array has to accommdate; after this call the array will be big enough to accommdate sizes up to accommodate_size

Definition at line 494 of file gnunet-service-testbed.h.

Function Documentation

◆ GST_destroy_peer()

void GST_destroy_peer ( struct Peer peer)

Function to destroy a peer.

Parameters
peerthe peer structure to destroy

Definition at line 260 of file gnunet-service-testbed_peers.c.

261 {
262  GNUNET_break (0 == peer->reference_cnt);
263  if (GNUNET_YES == peer->is_remote)
264  {
266  GNUNET_free (peer);
267  return;
268  }
269  if (GNUNET_YES == peer->details.local.is_running)
270  {
271  GNUNET_TESTING_peer_stop (peer->details.local.peer);
272  peer->details.local.is_running = GNUNET_NO;
273  }
274  GNUNET_TESTING_peer_destroy (peer->details.local.peer);
275  GNUNET_CONFIGURATION_destroy (peer->details.local.cfg);
277  GNUNET_free (peer);
278 }
static void peer_list_remove(struct Peer *peer)
Removes a the give peer from the peer array.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_free(ptr)
Wrapper around free.
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1485
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1566
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References GNUNET_break, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_NO, GNUNET_TESTING_peer_destroy(), GNUNET_TESTING_peer_stop(), GNUNET_YES, peer, and peer_list_remove().

Referenced by cleanup_mctx(), cleanup_occ(), cleanup_rocc(), handle_peer_destroy(), and peer_destroy_success_cb().

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

◆ GST_destroy_peers()

void GST_destroy_peers ( void  )

Stops and destroys all peers.

Definition at line 1410 of file gnunet-service-testbed_peers.c.

1411 {
1412  struct Peer *peer;
1413  unsigned int id;
1414 
1415  if (NULL == GST_peer_list)
1416  return;
1417  for (id = 0; id < GST_peer_list_size; id++)
1418  {
1419  peer = GST_peer_list[id];
1420  if (NULL == peer)
1421  continue;
1422  /* If destroy flag is set it means that this peer should have been
1423  * destroyed by a context which we destroy before */
1424  GNUNET_break (GNUNET_NO == peer->destroy_flag);
1425  /* counter should be zero as we free all contexts before */
1426  GNUNET_break (0 == peer->reference_cnt);
1427  if ((GNUNET_NO == peer->is_remote) &&
1428  (GNUNET_YES == peer->details.local.is_running))
1429  GNUNET_TESTING_peer_kill (peer->details.local.peer);
1430  }
1431  for (id = 0; id < GST_peer_list_size; id++)
1432  {
1433  peer = GST_peer_list[id];
1434  if (NULL == peer)
1435  continue;
1436  if (GNUNET_NO == peer->is_remote)
1437  {
1438  if (GNUNET_YES == peer->details.local.is_running)
1439  GNUNET_TESTING_peer_wait (peer->details.local.peer);
1440  GNUNET_TESTING_peer_destroy (peer->details.local.peer);
1441  GNUNET_CONFIGURATION_destroy (peer->details.local.cfg);
1442  }
1443  GNUNET_free (peer);
1444  }
1446  GST_peer_list = NULL;
1447  GST_peer_list_size = 0;
1448 }
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
unsigned int GST_peer_list_size
The size of the peer list.
struct Peer ** GST_peer_list
A list of peers we know about.
int GNUNET_TESTING_peer_kill(struct GNUNET_TESTING_Peer *peer)
Sends SIGTERM to the peer's main process.
Definition: testing.c:1430
int GNUNET_TESTING_peer_wait(struct GNUNET_TESTING_Peer *peer)
Waits for a peer to terminate.
Definition: testing.c:1462

References GNUNET_break, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_NO, GNUNET_TESTING_peer_destroy(), GNUNET_TESTING_peer_kill(), GNUNET_TESTING_peer_wait(), GNUNET_YES, GST_peer_list, GST_peer_list_size, id, and peer.

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_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 526 of file gnunet-service-testbed_links.c.

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

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

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

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 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define LOG_DEBUG(...)
Debug logging shorthand.
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
#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.
#define VALID_HOST_ID(id)
Condition to check if host id is valid.
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_CORE
Core service.
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 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 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.
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.
static void timeout_overlay_connect(void *cls)
Task which will be run when overlay connect request has been timed out.
@ 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...
#define LOG(kind,...)
Redefine LOG with a changed log component string.
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_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#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:1272
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.
Context information for connecting 2 peers in overlay.
struct RemotePeer2Context remote
Context information to be used if the second peer is remote.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
struct GNUNET_SERVICE_Client * client
The client which has requested for overlay connection.
uint64_t op_id
The id of the operation responsible for creating this context.
struct GST_ConnectionPool_GetHandle * cgh_ch
The GST_ConnectionPool_GetHandle for registering callback to notify CORE level peer connects and to g...
enum OverlayConnectContextType type
The type of this context information.
union OverlayConnectContext::@61 p2ctx
Context information for operations on the second peer.
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.
union Peer::@58 details
struct Peer::@58::@60 remote
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts.
uint32_t id
Our local reference id for this peer.
struct Peer::@58::@59 local
struct Neighbour * p2n
The neighbour handle.
struct NeighbourConnectNotification * ncn
Notification handle acquire to connect to a remote controller.
struct GNUNET_TESTBED_Controller * p2c
Controller of peer 2; If OCC_TYPE_REMOTE_LATERAL is the type of overlay connection then this can be N...

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:

◆ GST_queue_host_registration()

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.

Parameters
slavethe slave controller at which the given host has to be registered
cbthe host registration completion callback
cb_clsthe closure for the host registration completion callback
hostthe host which has to be registered

Definition at line 247 of file gnunet-service-testbed.c.

251 {
252  struct HostRegistration *hr;
253  int call_register;
254 
256  "Queueing host registration for host %u at %u\n",
259  hr = GNUNET_new (struct HostRegistration);
260  hr->cb = cb;
261  hr->cb_cls = cb_cls;
262  hr->host = host;
263  call_register = (NULL == slave->hr_dll_head) ? GNUNET_YES : GNUNET_NO;
265  slave->hr_dll_tail,
266  hr);
267  if (GNUNET_YES == call_register)
268  register_next_host (slave);
269 }
#define LOG(kind,...)
Definition: abd_api.c:38
static void register_next_host(struct Slave *slave)
Attempts to register the next host in the host registration queue.
@ GNUNET_ERROR_TYPE_DEBUG
A DLL of host registrations to be made.
struct GNUNET_TESTBED_Host * host
The host that has to be registered.
GNUNET_TESTBED_HostRegistrationCompletion cb
The callback to call after this registration's status is available.
void * cb_cls
The closure for the above callback.
uint32_t host_id
The id of the host this controller is running on.
struct HostRegistration * hr_dll_tail
Tail of the host registration DLL.
struct HostRegistration * hr_dll_head
Head of the host registration DLL.
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain a host's unique global ID.

References HostRegistration::cb, HostRegistration::cb_cls, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, GNUNET_TESTBED_host_get_id_(), GNUNET_YES, GST_host_list, HostRegistration::host, Slave::host_id, Slave::hr_dll_head, Slave::hr_dll_tail, LOG, and register_next_host().

Referenced by lcf_proc_task(), and register_host().

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

◆ GST_forwarded_operation_reply_relay()

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.

Parameters
clsForwardedOperationContext
msgthe message to relay

Definition at line 279 of file gnunet-service-testbed.c.

281 {
282  struct ForwardedOperationContext *fopc = cls;
283  struct GNUNET_MQ_Envelope *env;
284 
285  LOG_DEBUG ("Relaying message with type: %u, size: %u\n",
286  ntohs (msg->type),
287  ntohs (msg->size));
290  env);
293  fopcq_tail,
294  fopc);
295  GNUNET_free (fopc);
296 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
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
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:533
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2443
Context information for operations forwarded to subcontrollers.
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
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.

References ForwardedOperationContext::client, ForwardedOperationContext::cls, env, fopcq_head, fopcq_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_get_mq(), LOG_DEBUG, msg, GNUNET_MessageHeader::size, ForwardedOperationContext::timeout_task, and GNUNET_MessageHeader::type.

Referenced by forward_overlay_connect(), forwarded_overlay_connect_listener(), handle_manage_peer_service(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), peer_create_success_cb(), and peer_destroy_success_cb().

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

◆ GST_forwarded_operation_timeout()

void GST_forwarded_operation_timeout ( void *  cls)

Task to free resources when forwarded operation has been timed out.

Parameters
clsthe ForwardedOperationContext

Definition at line 300 of file gnunet-service-testbed.c.

301 {
302  struct ForwardedOperationContext *fopc = cls;
303 
304  fopc->timeout_task = NULL;
307  "A forwarded operation has timed out\n");
309  fopc->operation_id,
310  "A forwarded operation has timed out");
312  fopcq_tail,
313  fopc);
314  GNUNET_free (fopc);
315 }
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 OperationContext * opc
The generated operation context.
uint64_t operation_id
The id of the operation that has been forwarded.
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 ForwardedOperationContext::client, ForwardedOperationContext::cls, fopcq_head, fopcq_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_TESTBED_forward_operation_msg_cancel_(), GST_send_operation_fail_msg(), LOG, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, and ForwardedOperationContext::timeout_task.

Referenced by client_disconnect_cb(), forward_overlay_connect(), forwarded_overlay_connect_timeout(), GST_notify_client_disconnect_oc(), GST_notify_client_disconnect_peers(), handle_manage_peer_service(), handle_peer_destroy(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), and peer_create_forward_timeout().

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

◆ GST_clear_fopcq()

void GST_clear_fopcq ( void  )

Clears the forwarded operations queue.

Definition at line 677 of file gnunet-service-testbed.c.

678 {
679  struct ForwardedOperationContext *fopc;
680 
681  while (NULL != (fopc = fopcq_head))
682  {
684  fopcq_tail,
685  fopc);
687  if (NULL != fopc->timeout_task)
689  switch (fopc->type)
690  {
691  case OP_PEER_CREATE:
692  GNUNET_free (fopc->cls);
693  break;
694 
695  case OP_SHUTDOWN_PEERS:
696  {
697  struct HandlerContext_ShutdownPeers *hc = fopc->cls;
698 
699  GNUNET_assert (0 < hc->nslaves);
700  hc->nslaves--;
701  if (0 == hc->nslaves)
702  GNUNET_free (hc);
703  }
704  break;
705 
706  case OP_PEER_START:
707  case OP_PEER_STOP:
708  case OP_PEER_DESTROY:
709  case OP_PEER_INFO:
710  case OP_OVERLAY_CONNECT:
711  case OP_LINK_CONTROLLERS:
712  case OP_GET_SLAVE_CONFIG:
713  case OP_MANAGE_SERVICE:
714  case OP_PEER_RECONFIGURE:
715  break;
716 
717  case OP_FORWARDED:
718  GNUNET_assert (0);
719  }
720  ;
721  GNUNET_free (fopc);
722  }
723 }
enum OperationType type
The type of the operation which is forwarded.
Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler.
unsigned int nslaves
The number of slave we expect to hear from since we forwarded the GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOW...
@ OP_GET_SLAVE_CONFIG
Get slave config operation.
Definition: testbed_api.h:94
@ OP_PEER_RECONFIGURE
Reconfigure a peer.
Definition: testbed_api.h:74
@ OP_FORWARDED
Forwarded operation.
Definition: testbed_api.h:84
@ OP_PEER_START
Peer start operation.
Definition: testbed_api.h:54
@ OP_PEER_INFO
Get peer information operation.
Definition: testbed_api.h:69
@ OP_SHUTDOWN_PEERS
Stop and destroy all peers.
Definition: testbed_api.h:99
@ OP_MANAGE_SERVICE
Start/stop service at a peer.
Definition: testbed_api.h:104
@ OP_PEER_DESTROY
Peer destroy operation.
Definition: testbed_api.h:64
@ OP_OVERLAY_CONNECT
Overlay connection operation.
Definition: testbed_api.h:79
@ OP_LINK_CONTROLLERS
Link controllers operation.
Definition: testbed_api.h:89
@ OP_PEER_STOP
Peer stop operation.
Definition: testbed_api.h:59
@ OP_PEER_CREATE
Peer create operation.
Definition: testbed_api.h:49

References ForwardedOperationContext::cls, fopcq_head, fopcq_tail, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_forward_operation_msg_cancel_(), HandlerContext_ShutdownPeers::nslaves, OP_FORWARDED, OP_GET_SLAVE_CONFIG, OP_LINK_CONTROLLERS, OP_MANAGE_SERVICE, OP_OVERLAY_CONNECT, OP_PEER_CREATE, OP_PEER_DESTROY, OP_PEER_INFO, OP_PEER_RECONFIGURE, OP_PEER_START, OP_PEER_STOP, OP_SHUTDOWN_PEERS, ForwardedOperationContext::opc, ForwardedOperationContext::timeout_task, and ForwardedOperationContext::type.

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

void GST_send_operation_fail_msg ( struct GNUNET_SERVICE_Client client,
uint64_t  operation_id,
const char *  emsg 
)

Send operation failure message to client.

Parameters
clientthe client to which the failure message has to be sent to
operation_idthe id of the failed operation
emsgthe error message; can be NULL

Definition at line 125 of file gnunet-service-testbed.c.

128 {
129  struct GNUNET_MQ_Envelope *env;
131  uint16_t emsg_len;
132 
133  emsg_len = (NULL == emsg) ? 0 : strlen (emsg) + 1;
135  emsg_len,
137  msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED);
138  msg->operation_id = GNUNET_htonll (operation_id);
139  GNUNET_memcpy (&msg[1],
140  emsg,
141  emsg_len);
143  env);
144 }
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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:63
#define GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
Message for operation events.
@ GNUNET_TESTBED_ET_OPERATION_FINISHED
A requested testbed operation has been completed.
Event notification from a controller to a client.
Definition: testbed.h:509
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:524

References env, GNUNET_htonll(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_OPERATION_FINISHED, msg, and GNUNET_TESTBED_OperationFailureEventMessage::operation_id.

Referenced by GST_forwarded_operation_timeout(), handle_manage_peer_service(), handle_peer_create(), handle_peer_destroy(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), handle_slave_get_config(), prc_stop_cb(), service_manage_result_cb(), shutdown_peers_reply_cb(), and timeout_overlay_connect().

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 }
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
static void cleanup_occ(struct OverlayConnectContext *occ)
Cleanup overlay connect context structure.
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:

◆ GST_notify_client_disconnect_peers()

void GST_notify_client_disconnect_peers ( struct GNUNET_SERVICE_Client client)

Notify peers subsystem that client disconnected.

Parameters
clientthe client that disconnected

Definition at line 355 of file gnunet-service-testbed_peers.c.

356 {
357  struct ForwardedOperationContext *fopc;
358  struct ForwardedOperationContext *fopcn;
359  struct ManageServiceContext *mctx;
360  struct ManageServiceContext *mctxn;
361  struct PeerReconfigureContext *prc;
362  struct PeerReconfigureContext *prcn;
363 
364  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
365  {
366  fopcn = fopc->next;
367  if (client == fopc->client)
368  {
369  if (OP_PEER_CREATE == fopc->type)
370  GNUNET_free (fopc->cls);
373  }
374  }
375  for (mctx = mctx_head; NULL != mctx; mctx = mctxn)
376  {
377  mctxn = mctx->next;
378  if (client == mctx->client)
379  cleanup_mctx (mctx);
380  }
381  for (prc = prc_head; NULL != prc; prc = prcn)
382  {
383  prcn = prc->next;
384  if (client == prc->client)
385  cleanup_prc (prc);
386  }
387 }
static void cleanup_prc(struct PeerReconfigureContext *prc)
Cleans up the given PeerReconfigureContext.
static void cleanup_mctx(struct ManageServiceContext *mctx)
Cleanup the context information created for managing a peer's service.
static struct PeerReconfigureContext * prc_head
The DLL head for the peer reconfigure list.
static struct ManageServiceContext * mctx_head
DLL head for queue of manage service requests.
Context information to manage peers' services.
struct ManageServiceContext * next
DLL next ptr.
struct GNUNET_SERVICE_Client * client
The client which requested to manage the peer's service.
Context information for peer re-configure operations.
struct GNUNET_SERVICE_Client * client
The client which gave this operation to us.
struct PeerReconfigureContext * next
DLL next for inclusoin in peer reconfigure operations list.

References cleanup_mctx(), cleanup_prc(), ForwardedOperationContext::client, ManageServiceContext::client, PeerReconfigureContext::client, ForwardedOperationContext::cls, fopcq_head, GNUNET_free, GNUNET_SCHEDULER_cancel(), GST_forwarded_operation_timeout(), mctx_head, ForwardedOperationContext::next, ManageServiceContext::next, PeerReconfigureContext::next, OP_PEER_CREATE, prc_head, ForwardedOperationContext::timeout_task, and ForwardedOperationContext::type.

Referenced by client_disconnect_cb().

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

◆ GST_send_operation_success_msg()

void GST_send_operation_success_msg ( struct GNUNET_SERVICE_Client client,
uint64_t  operation_id 
)

Function to send generic operation success message to given client.

Parameters
clientthe client to send the message to
operation_idthe id of the operation which was successful

Definition at line 154 of file gnunet-service-testbed.c.

156 {
157  struct GNUNET_MQ_Envelope *env;
159 
160  env = GNUNET_MQ_msg (msg,
162  msg->operation_id = GNUNET_htonll (operation_id);
163  msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED);
165  env);
166 }
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
Message to signal a generic operation has been successful.
Event notification from a controller to a client for a generic operational success where the operatio...
Definition: testbed.h:558
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:573

References env, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_OPERATION_FINISHED, msg, and GNUNET_TESTBED_GenericOperationSuccessEventMessage::operation_id.

Referenced by handle_peer_destroy(), handle_peer_reconfigure(), handle_shutdown_peers(), prc_stop_cb(), service_manage_result_cb(), and shutdown_peers_reply_cb().

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
@ GNUNET_OK
@ GNUNET_SYSERR
#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.
Message sent from host controller of a peer(A) to the host controller of another peer(B) to request B...
Definition: testbed.h:409

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 }
@ GST_CONNECTIONPOOL_SERVICE_TRANSPORT
Transport service.
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 void timeout_rocc_task(void *cls)
Task to timeout rocc and cleanit up.
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.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
Definition: strings.c:138
struct GST_ConnectionPool_GetHandle * cgh_p2_th
The GetCacheHandle for the peer2's transport handle (used to offer the HELLO to the peer).
Header for all communications.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
Context information for remote overlay connect operations.
struct ConnectivitySuggestContext tcc
The transport try connect context.
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_PeerIdentity a_id
The peer identity of peer A.
struct GNUNET_MessageHeader * hello
Peer A's HELLO.
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 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:

◆ check_peer_create()

int check_peer_create ( void *  cls,
const struct GNUNET_TESTBED_PeerCreateMessage msg 
)

Check #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.

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

Definition at line 425 of file gnunet-service-testbed_peers.c.

427 {
428  return GNUNET_OK; /* checked later */
429 }

References GNUNET_OK.

◆ handle_peer_create()

void handle_peer_create ( void *  cls,
const struct GNUNET_TESTBED_PeerCreateMessage msg 
)

Handler for #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 433 of file gnunet-service-testbed_peers.c.

435 {
436  struct GNUNET_SERVICE_Client *client = cls;
437  struct GNUNET_MQ_Envelope *env;
440  struct ForwardedOperationContext *fo_ctxt;
441  struct Route *route;
442  struct Peer *peer;
443  char *emsg;
444  uint32_t host_id;
445  uint32_t peer_id;
446 
447  host_id = ntohl (msg->host_id);
448  peer_id = ntohl (msg->peer_id);
449  if (VALID_PEER_ID (peer_id))
450  {
451  (void) GNUNET_asprintf (&emsg,
452  "Peer with ID %u already exists",
453  peer_id);
455  GNUNET_ntohll (msg->operation_id),
456  emsg);
457  GNUNET_free (emsg);
459  return;
460  }
461  if (UINT32_MAX == peer_id)
462  {
464  GNUNET_ntohll (msg->operation_id),
465  "Cannot create peer with given ID");
467  return;
468  }
469  if (host_id == GST_context->host_id)
470  {
471  /* We are responsible for this peer */
473  if (NULL == cfg)
474  {
475  GNUNET_break (0);
477  return;
478  }
480  "TESTBED",
481  "PEERID",
482  (unsigned long long) peer_id);
483 
485  "PATHS",
486  "PEERID",
487  (unsigned long long) peer_id);
488  peer = GNUNET_new (struct Peer);
489  peer->is_remote = GNUNET_NO;
490  peer->details.local.cfg = cfg;
491  peer->id = peer_id;
492  LOG_DEBUG ("Creating peer with id: %u\n",
493  (unsigned int) peer->id);
494  peer->details.local.peer =
496  peer->details.local.cfg, peer->id,
497  NULL /* Peer id */,
498  &emsg);
499  if (NULL == peer->details.local.peer)
500  {
502  "Configuring peer failed: %s\n",
503  emsg);
504  GNUNET_free (emsg);
505  GNUNET_free (peer);
506  GNUNET_break (0);
508  return;
509  }
510  peer->details.local.is_running = GNUNET_NO;
512  env = GNUNET_MQ_msg (reply,
514  reply->peer_id = msg->peer_id;
515  reply->operation_id = msg->operation_id;
517  env);
519  return;
520  }
521 
522  /* Forward peer create request */
523  route = GST_find_dest_route (host_id);
524  if (NULL == route)
525  {
526  GNUNET_break (0);
527  GNUNET_SERVICE_client_continue (client); // ?
528  return;
529  }
530  peer = GNUNET_new (struct Peer);
531  peer->is_remote = GNUNET_YES;
532  peer->id = peer_id;
533  peer->details.remote.slave = GST_slave_list[route->dest];
534  peer->details.remote.remote_host_id = host_id;
535  fo_ctxt = GNUNET_new (struct ForwardedOperationContext);
536  fo_ctxt->client = client;
537  fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
538  fo_ctxt->cls = peer;
539  fo_ctxt->type = OP_PEER_CREATE;
540  fo_ctxt->opc =
542  [route->dest]->controller,
543  fo_ctxt->operation_id,
544  &msg->header,
546  fo_ctxt);
547  fo_ctxt->timeout_task =
550  fo_ctxt);
552  fopcq_tail,
553  fo_ctxt);
555 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct Route * GST_find_dest_route(uint32_t host_id)
Finds the route with directly connected host as destination through which the destination host can be...
static void peer_create_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer create operation is successful.
static void peer_list_add(struct Peer *peer)
Adds a peer to the peer array.
static void peer_create_forward_timeout(void *cls)
The task to be executed if the forwarded peer create operation has been timed out.
void GNUNET_CONFIGURATION_set_value_number(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number)
Set a configuration value that should be a number.
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
Message to signal successful peer creation.
struct GNUNET_TESTING_Peer * GNUNET_TESTING_peer_configure(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t key_number, struct GNUNET_PeerIdentity *id, char **emsg)
Configure a GNUnet peer.
Definition: testing.c:1188
struct GNUNET_TESTING_System * system
The TESTING system handle for starting peers locally.
Event notification from a controller to a client.
Definition: testbed.h:534
uint32_t peer_id
Peer identity of the peer that was created.
Definition: testbed.h:543
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:548
uint32_t dest
destination host
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_extract_config_(const struct GNUNET_MessageHeader *msg)
Generates configuration by uncompressing configuration in given message.
Definition: testbed_api.c:2043
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

References cfg, ForwardedOperationContext::client, ForwardedOperationContext::cls, Slave::controller, Route::dest, env, fopcq_head, fopcq_tail, GNUNET_asprintf(), GNUNET_break, GNUNET_CONFIGURATION_set_value_number(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_NO, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_extract_config_(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTING_peer_configure(), GNUNET_YES, GST_context, GST_find_dest_route(), GST_send_operation_fail_msg(), GST_slave_list, GST_timeout, Context::host_id, LOG, LOG_DEBUG, msg, OP_PEER_CREATE, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_PeerCreateSuccessEventMessage::operation_id, peer, peer_create_forward_timeout(), peer_create_success_cb(), peer_id, GNUNET_TESTBED_PeerCreateSuccessEventMessage::peer_id, peer_list_add(), Context::system, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

Here is the call graph for this function:

◆ handle_peer_destroy()

void handle_peer_destroy ( void *  cls,
const struct GNUNET_TESTBED_PeerDestroyMessage msg 
)

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 565 of file gnunet-service-testbed_peers.c.

567 {
568  struct GNUNET_SERVICE_Client *client = cls;
569  struct ForwardedOperationContext *fopc;
570  struct Peer *peer;
571  uint32_t peer_id;
572 
573  peer_id = ntohl (msg->peer_id);
574  LOG_DEBUG ("Received peer destroy on peer: %u and operation id: %llu\n",
575  (unsigned int) peer_id,
576  (unsigned long long) GNUNET_ntohll (msg->operation_id));
577  if (! VALID_PEER_ID (peer_id))
578  {
580  "Asked to destroy a non existent peer with id: %u\n", peer_id);
582  GNUNET_ntohll (msg->operation_id),
583  "Peer doesn't exist");
585  return;
586  }
588  if (GNUNET_YES == peer->is_remote)
589  {
590  /* Forward the destroy message to sub controller */
591  fopc = GNUNET_new (struct ForwardedOperationContext);
592  fopc->client = client;
593  fopc->cls = peer;
594  fopc->type = OP_PEER_DESTROY;
595  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
596  fopc->opc =
598  slave->controller,
599  fopc->operation_id,
600  &msg->header,
602  fopc);
603  fopc->timeout_task =
606  fopc);
608  fopcq_tail,
609  fopc);
611  return;
612  }
613  peer->destroy_flag = GNUNET_YES;
614  if (0 == peer->reference_cnt)
616  else
618  "Delaying peer destroy as peer is currently in use\n");
620  GNUNET_ntohll (msg->operation_id));
622 }
void GST_send_operation_success_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id)
Function to send generic operation success message to given client.
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
static void peer_destroy_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer destroy operation is successful.
@ GNUNET_ERROR_TYPE_ERROR
struct Slave * slave
The slave this peer is started through.

References ForwardedOperationContext::client, ForwardedOperationContext::cls, Slave::controller, fopcq_head, fopcq_tail, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_new, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_YES, GST_destroy_peer(), GST_forwarded_operation_timeout(), GST_peer_list, GST_send_operation_fail_msg(), GST_send_operation_success_msg(), GST_timeout, LOG, LOG_DEBUG, msg, OP_PEER_DESTROY, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, peer, peer_destroy_success_cb(), peer_id, Peer::slave, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

Here is the call graph for this function:

◆ handle_peer_start()

void handle_peer_start ( void *  cls,
const struct GNUNET_TESTBED_PeerStartMessage msg 
)

Message handler for GNUNET_MESSAGE_TYPE_TESTBED_START_PEER messages.

Parameters
clsidentification of the client
msgthe actual message

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

645 {
646  struct GNUNET_SERVICE_Client *client = cls;
647  struct GNUNET_MQ_Envelope *env;
648  struct GNUNET_TESTBED_PeerEventMessage *reply;
649  struct ForwardedOperationContext *fopc;
650  struct Peer *peer;
651  uint32_t peer_id;
652 
653  peer_id = ntohl (msg->peer_id);
654  if (! VALID_PEER_ID (peer_id))
655  {
656  GNUNET_break (0);
658  "Asked to start a non existent peer with id: %u\n",
659  peer_id);
661  return;
662  }
664  if (GNUNET_YES == peer->is_remote)
665  {
666  fopc = GNUNET_new (struct ForwardedOperationContext);
667  fopc->client = client;
668  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
669  fopc->type = OP_PEER_START;
670  fopc->opc =
672  slave->controller,
673  fopc->operation_id, &msg->header,
674  &
676  fopc);
677  fopc->timeout_task =
680  fopc);
682  fopcq_tail,
683  fopc);
685  return;
686  }
687  if (GNUNET_OK != start_peer (peer))
688  {
689  GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
690  "Failed to start");
692  return;
693  }
694  env = GNUNET_MQ_msg (reply,
696  reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_START);
697  reply->host_id = htonl (GST_context->host_id);
698  reply->peer_id = msg->peer_id;
699  reply->operation_id = msg->operation_id;
701  env);
703 }
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.
static int start_peer(struct Peer *peer)
Stats a peer.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
Message for peer events.
@ GNUNET_TESTBED_ET_PEER_START
A peer has been started.
Event notification from a controller to a client.
Definition: testbed.h:443
uint32_t peer_id
Peer that was started or stopped.
Definition: testbed.h:463
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:468
int32_t event_type
enum GNUNET_TESTBED_EventType (in NBO); either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER...
Definition: testbed.h:453
uint32_t host_id
Host where the peer is running.
Definition: testbed.h:458

References ForwardedOperationContext::client, Slave::controller, env, GNUNET_TESTBED_PeerEventMessage::event_type, fopcq_head, fopcq_tail, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_ntohll(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_PEER_START, GNUNET_TESTBED_forward_operation_msg_(), GNUNET_YES, GST_context, GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_peer_list, GST_send_operation_fail_msg(), GST_timeout, Context::host_id, GNUNET_TESTBED_PeerEventMessage::host_id, LOG, msg, OP_PEER_START, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_PeerEventMessage::operation_id, peer, peer_id, GNUNET_TESTBED_PeerEventMessage::peer_id, Peer::slave, start_peer(), ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

Here is the call graph for this function:

◆ handle_peer_stop()

void handle_peer_stop ( void *  cls,
const struct GNUNET_TESTBED_PeerStopMessage msg 
)

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.

Parameters
clsidentification of the client
msgthe actual message

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 713 of file gnunet-service-testbed_peers.c.

715 {
716  struct GNUNET_SERVICE_Client *client = cls;
717  struct GNUNET_MQ_Envelope *env;
718  struct GNUNET_TESTBED_PeerEventMessage *reply;
719  struct ForwardedOperationContext *fopc;
720  struct Peer *peer;
721  uint32_t peer_id;
722 
723  peer_id = ntohl (msg->peer_id);
725  "Received PEER_STOP for peer %u\n",
726  (unsigned int) peer_id);
727  if (! VALID_PEER_ID (peer_id))
728  {
730  GNUNET_ntohll (msg->operation_id),
731  "Peer not found");
733  return;
734  }
736  if (GNUNET_YES == peer->is_remote)
737  {
739  "Forwarding PEER_STOP for peer %u\n",
740  (unsigned int) peer_id);
741  fopc = GNUNET_new (struct ForwardedOperationContext);
742  fopc->client = client;
743  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
744  fopc->type = OP_PEER_STOP;
745  fopc->opc =
747  slave->controller,
748  fopc->operation_id,
749  &msg->header,
750  &
752  fopc);
753  fopc->timeout_task =
756  fopc);
758  fopcq_tail,
759  fopc);
761  return;
762  }
763  if (GNUNET_OK != stop_peer (peer))
764  {
766  "Stopping peer %u failed\n",
767  (unsigned int) peer_id);
769  GNUNET_ntohll (msg->operation_id),
770  "Peer not running");
772  return;
773  }
775  "Peer %u successfully stopped\n",
776  (unsigned int) peer_id);
777  env = GNUNET_MQ_msg (reply,
779  reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_STOP);
780  reply->host_id = htonl (GST_context->host_id);
781  reply->peer_id = msg->peer_id;
782  reply->operation_id = msg->operation_id;
784  env);
786  GNUNET_TESTING_peer_wait (peer->details.local.peer);
787 }
static int stop_peer(struct Peer *peer)
Stops a peer.
@ GNUNET_TESTBED_ET_PEER_STOP
A peer has been stopped.

References ForwardedOperationContext::client, Slave::controller, env, GNUNET_TESTBED_PeerEventMessage::event_type, fopcq_head, fopcq_tail, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_ntohll(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_PEER_STOP, GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTING_peer_wait(), GNUNET_YES, GST_context, GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_peer_list, GST_send_operation_fail_msg(), GST_timeout, Context::host_id, GNUNET_TESTBED_PeerEventMessage::host_id, LOG, msg, OP_PEER_STOP, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_PeerEventMessage::operation_id, peer, peer_id, GNUNET_TESTBED_PeerEventMessage::peer_id, Peer::slave, stop_peer(), ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

Here is the call graph for this function:

◆ handle_peer_get_config()

void handle_peer_get_config ( void *  cls,
const struct GNUNET_TESTBED_PeerGetConfigurationMessage msg 
)

Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG messages.

Parameters
clsidentification of the client
msgthe actual message

Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 797 of file gnunet-service-testbed_peers.c.

800 {
801  struct GNUNET_SERVICE_Client *client = cls;
802  struct GNUNET_MQ_Envelope *env;
804  struct ForwardedOperationContext *fopc;
805  struct Peer *peer;
806  char *config;
807  char *xconfig;
808  size_t c_size;
809  size_t xc_size;
810  uint32_t peer_id;
811 
812  peer_id = ntohl (msg->peer_id);
813  LOG_DEBUG ("Received GET_CONFIG for peer %u\n",
814  (unsigned int) peer_id);
815  if (! VALID_PEER_ID (peer_id))
816  {
818  GNUNET_ntohll (msg->operation_id),
819  "Peer not found");
821  return;
822  }
824  if (GNUNET_YES == peer->is_remote)
825  {
826  LOG_DEBUG ("Forwarding PEER_GET_CONFIG for peer: %u\n",
827  (unsigned int) peer_id);
828  fopc = GNUNET_new (struct ForwardedOperationContext);
829  fopc->client = client;
830  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
831  fopc->type = OP_PEER_INFO;
832  fopc->opc =
834  slave->controller,
835  fopc->operation_id,
836  &msg->header,
837  &
839  fopc);
840  fopc->timeout_task =
843  fopc);
845  fopcq_tail,
846  fopc);
848  return;
849  }
850  LOG_DEBUG ("Received PEER_GET_CONFIG for peer: %u\n",
851  peer_id);
852  config =
854  &c_size);
856  c_size,
857  &xconfig);
859  env = GNUNET_MQ_msg_extra (reply,
860  xc_size,
862  reply->peer_id = msg->peer_id;
863  reply->operation_id = msg->operation_id;
865  &reply->peer_identity);
866  reply->config_size = htons ((uint16_t) c_size);
867  GNUNET_memcpy (&reply[1],
868  xconfig,
869  xc_size);
870  GNUNET_free (xconfig);
872  env);
874 }
static const struct GNUNET_CONFIGURATION_Handle * config
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
#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
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:618
struct GNUNET_PeerIdentity peer_identity
Identity of the peer.
Definition: testbed.h:623
uint16_t config_size
The size of configuration when uncompressed.
Definition: testbed.h:628
uint32_t peer_id
The id of the peer relevant to this information.
Definition: testbed.h:613
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1758

References ForwardedOperationContext::client, config, GNUNET_TESTBED_PeerConfigurationInformationMessage::config_size, Slave::controller, Peer::details, env, fopcq_head, fopcq_tail, GNUNET_CONFIGURATION_serialize(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_compress_config_(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTING_peer_get_identity(), GNUNET_YES, GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_peer_list, GST_send_operation_fail_msg(), GST_timeout, LOG_DEBUG, msg, OP_PEER_INFO, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_PeerConfigurationInformationMessage::operation_id, peer, peer_id, GNUNET_TESTBED_PeerConfigurationInformationMessage::peer_id, GNUNET_TESTBED_PeerConfigurationInformationMessage::peer_identity, Peer::slave, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

Here is the call graph for this function:

◆ handle_shutdown_peers()

void handle_shutdown_peers ( void *  cls,
const struct GNUNET_TESTBED_ShutdownPeersMessage msg 
)

Handler for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 1498 of file gnunet-service-testbed_peers.c.

1500 {
1501  struct GNUNET_SERVICE_Client *client = cls;
1502  struct HandlerContext_ShutdownPeers *hc;
1503  struct Slave *slave;
1504  struct ForwardedOperationContext *fo_ctxt;
1505  uint64_t op_id;
1506  unsigned int cnt;
1507 
1508  LOG_DEBUG ("Received SHUTDOWN_PEERS\n");
1509  /* Stop and destroy all peers */
1510  GST_free_mctxq ();
1511  GST_free_occq ();
1512  GST_free_roccq ();
1513  GST_clear_fopcq ();
1514  /* Forward to all slaves which we have started */
1515  op_id = GNUNET_ntohll (msg->operation_id);
1517  /* FIXME: have a better implementation where we track which slaves are
1518  started by this controller */
1519  for (cnt = 0; cnt < GST_slave_list_size; cnt++)
1520  {
1521  slave = GST_slave_list[cnt];
1522  if (NULL == slave)
1523  continue;
1524  if (NULL == slave->controller_proc) /* We didn't start the slave */
1525  continue;
1526  LOG_DEBUG ("Forwarding SHUTDOWN_PEERS\n");
1527  hc->nslaves++;
1528  fo_ctxt = GNUNET_new (struct ForwardedOperationContext);
1529  fo_ctxt->client = client;
1530  fo_ctxt->operation_id = op_id;
1531  fo_ctxt->cls = hc;
1532  fo_ctxt->type = OP_SHUTDOWN_PEERS;
1533  fo_ctxt->opc =
1535  fo_ctxt->operation_id,
1536  &msg->header,
1538  fo_ctxt);
1540  fopcq_tail,
1541  fo_ctxt);
1542  }
1543  LOG_DEBUG ("Shutting down peers\n");
1544  GST_destroy_peers ();
1545  if (0 == hc->nslaves)
1546  {
1548  op_id);
1549  GNUNET_free (hc);
1550  }
1552 }
void GST_clear_fopcq()
Clears the forwarded operations queue.
void GST_free_roccq(void)
Clears all pending remote overlay connect contexts in queue.
void GST_free_occq(void)
Clears all pending overlay connect contexts in queue.
static void shutdown_peers_reply_cb(void *cls, const struct GNUNET_MessageHeader *msg)
The reply msg handler forwarded SHUTDOWN_PEERS operation.
void GST_free_mctxq()
Frees the ManageServiceContext queue.
void GST_destroy_peers()
Stops and destroys all peers.
Structure representing a connected(directly-linked) controller.
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.

References ForwardedOperationContext::client, ForwardedOperationContext::cls, Slave::controller, Slave::controller_proc, fopcq_head, fopcq_tail, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_free, GNUNET_new, GNUNET_ntohll(), GNUNET_SERVICE_client_continue(), GNUNET_TESTBED_forward_operation_msg_(), GST_clear_fopcq(), GST_destroy_peers(), GST_free_mctxq(), GST_free_occq(), GST_free_roccq(), GST_send_operation_success_msg(), GST_slave_list, GST_slave_list_size, LOG_DEBUG, msg, HandlerContext_ShutdownPeers::nslaves, OP_SHUTDOWN_PEERS, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, shutdown_peers_reply_cb(), and ForwardedOperationContext::type.

Here is the call graph for this function:

◆ check_manage_peer_service()

int check_manage_peer_service ( void *  cls,
const struct GNUNET_TESTBED_ManagePeerServiceMessage msg 
)

Check GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message.

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

Definition at line 1269 of file gnunet-service-testbed_peers.c.

1272 {
1273  uint16_t msize;
1274  const char*service;
1275 
1276  msize = ntohs (msg->header.size);
1277  service = (const char *) &msg[1];
1278  if ('\0' != service[msize - sizeof
1280  {
1281  GNUNET_break_op (0);
1282  return GNUNET_SYSERR;
1283  }
1284  if (1 < msg->start)
1285  {
1286  GNUNET_break_op (0);
1287  return GNUNET_SYSERR;
1288  }
1289  return GNUNET_OK;
1290 }
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
Message to start/stop services of a peer.
Definition: testbed.h:706

References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, msg, service, and GNUNET_MessageHeader::size.

◆ handle_manage_peer_service()

void handle_manage_peer_service ( void *  cls,
const struct GNUNET_TESTBED_ManagePeerServiceMessage msg 
)

Handler for GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE messages.

Parameters
clsidentification of client
msgthe actual message

Definition at line 1294 of file gnunet-service-testbed_peers.c.

1297 {
1298  struct GNUNET_SERVICE_Client *client = cls;
1299  const char*service;
1300  struct Peer *peer;
1301  char *emsg;
1302  struct GNUNET_ARM_Handle *ah;
1303  struct ManageServiceContext *mctx;
1304  struct ForwardedOperationContext *fopc;
1305  uint64_t op_id;
1306  uint32_t peer_id;
1307 
1308  service = (const char *) &msg[1];
1309  peer_id = ntohl (msg->peer_id);
1310  op_id = GNUNET_ntohll (msg->operation_id);
1311  LOG_DEBUG ("Received request to manage service %s on peer %u\n",
1312  service, (unsigned int) peer_id);
1313  if ((GST_peer_list_size <= peer_id)
1314  || (NULL == (peer = GST_peer_list[peer_id])))
1315  {
1316  GNUNET_asprintf (&emsg, "Asked to manage service of a non existent peer "
1317  "with id: %u", peer_id);
1318  goto err_ret;
1319  }
1320  if (0 == strcasecmp ("arm", service))
1321  {
1322  emsg = GNUNET_strdup ("Cannot start/stop peer's ARM service. "
1323  "Use peer start/stop for that");
1324  goto err_ret;
1325  }
1326  if (GNUNET_YES == peer->is_remote)
1327  {
1328  /* Forward the destroy message to sub controller */
1329  fopc = GNUNET_new (struct ForwardedOperationContext);
1330  fopc->client = client;
1331  fopc->cls = peer;
1332  fopc->type = OP_MANAGE_SERVICE;
1333  fopc->operation_id = op_id;
1334  fopc->opc =
1336  slave->controller,
1337  fopc->operation_id,
1338  &msg->header,
1339  &
1341  fopc);
1342  fopc->timeout_task =
1345  fopc);
1347  fopcq_tail,
1348  fopc);
1350  return;
1351  }
1352  if (GNUNET_NO == peer->details.local.is_running)
1353  {
1354  emsg = GNUNET_strdup ("Peer not running\n");
1355  goto err_ret;
1356  }
1357  if ((0 != peer->reference_cnt)
1358  && ((0 == strcasecmp ("core", service))
1359  || (0 == strcasecmp ("transport", service))))
1360  {
1361  GNUNET_asprintf (&emsg, "Cannot stop %s service of peer with id: %u "
1362  "since it is required by existing operations",
1363  service, peer_id);
1364  goto err_ret;
1365  }
1366  ah = GNUNET_ARM_connect (peer->details.local.cfg, NULL, NULL);
1367  if (NULL == ah)
1368  {
1369  GNUNET_asprintf (&emsg,
1370  "Cannot connect to ARM service of peer with id: %u",
1371  peer_id);
1372  goto err_ret;
1373  }
1374  mctx = GNUNET_new (struct ManageServiceContext);
1375  mctx->peer = peer;
1376  peer->reference_cnt++;
1377  mctx->op_id = op_id;
1378  mctx->ah = ah;
1379  mctx->client = client;
1380  mctx->start = msg->start;
1381  mctx->service = GNUNET_strdup (service);
1383  mctx_tail,
1384  mctx);
1385  if (1 == mctx->start)
1387  service,
1390  mctx);
1391  else
1394  mctx);
1396  return;
1397 
1398 err_ret:
1399  LOG (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
1400  GST_send_operation_fail_msg (client, op_id, emsg);
1401  GNUNET_free (emsg);
1403 }
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.
static void service_manage_result_cb(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
Function called in response to a start/stop request.
static struct ManageServiceContext * mctx_tail
DLL tail for queue of manage service requests.
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_start(struct GNUNET_ARM_Handle *h, const char *service_name, enum GNUNET_OS_InheritStdioFlags std_inheritance, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request for a service to be started.
Definition: arm_api.c:926
struct GNUNET_ARM_Handle * GNUNET_ARM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ConnectionStatusCallback conn_status, void *conn_status_cls)
Set up a context for communicating with ARM, then start connecting to the ARM service using that cont...
Definition: arm_api.c:577
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_stop(struct GNUNET_ARM_Handle *h, const char *service_name, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request a service to be stopped.
Definition: arm_api.c:1038
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
@ GNUNET_OS_INHERIT_STD_ERR
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:95
Handle for interacting with ARM.
Definition: arm_api.c:103
uint64_t op_id
The operation id of the associated request.
struct GNUNET_ARM_Handle * ah
The ARM handle of the peer.
uint8_t start
1 if the service at the peer has to be started; 0 if it has to be stopped
char * service
Name of the service.
struct Peer * peer
peer whose service has to be managed

References ah, ManageServiceContext::ah, ForwardedOperationContext::client, ManageServiceContext::client, ForwardedOperationContext::cls, GNUNET_TESTBED_Peer::controller, fopcq_head, fopcq_tail, GNUNET_ARM_connect(), GNUNET_ARM_request_service_start(), GNUNET_ARM_request_service_stop(), GNUNET_asprintf(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_ntohll(), GNUNET_OS_INHERIT_STD_ERR, GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_TESTBED_forward_operation_msg_(), GNUNET_YES, GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_peer_list, GST_peer_list_size, GST_send_operation_fail_msg(), GST_timeout, LOG, LOG_DEBUG, mctx_head, mctx_tail, msg, ManageServiceContext::op_id, OP_MANAGE_SERVICE, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, ManageServiceContext::peer, peer, peer_id, service, ManageServiceContext::service, service_manage_result_cb(), ManageServiceContext::start, ForwardedOperationContext::timeout_task, and ForwardedOperationContext::type.

Here is the call graph for this function:

◆ check_peer_reconfigure()

int check_peer_reconfigure ( void *  cls,
const struct GNUNET_TESTBED_PeerReconfigureMessage msg 
)

Check #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.

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

Definition at line 969 of file gnunet-service-testbed_peers.c.

971 {
972  return GNUNET_OK; /* checked later */
973 }

References GNUNET_OK.

◆ handle_peer_reconfigure()

void handle_peer_reconfigure ( void *  cls,
const struct GNUNET_TESTBED_PeerReconfigureMessage msg 
)

Handler for #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.

Should stop the peer asynchronously, destroy it and create it again with the new configuration.

Parameters
clsidentification of the client
msgthe actual message

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

988 {
989  struct GNUNET_SERVICE_Client *client = cls;
990  struct Peer *peer;
992  struct ForwardedOperationContext *fopc;
993  struct PeerReconfigureContext *prc;
994  char *emsg;
995  uint64_t op_id;
996  uint32_t peer_id;
997 
998  peer_id = ntohl (msg->peer_id);
999  op_id = GNUNET_ntohll (msg->operation_id);
1000  if (! VALID_PEER_ID (peer_id))
1001  {
1002  GNUNET_break (0);
1004  op_id,
1005  "Peer not found");
1007  return;
1008  }
1010  if (GNUNET_YES == peer->is_remote)
1011  {
1012  LOG_DEBUG ("Forwarding PEER_RECONFIGURE for peer: %u\n", peer_id);
1013  fopc = GNUNET_new (struct ForwardedOperationContext);
1014  fopc->client = client;
1015  fopc->operation_id = op_id;
1016  fopc->type = OP_PEER_RECONFIGURE;
1017  fopc->opc =
1019  slave->controller,
1020  fopc->operation_id,
1021  &msg->header,
1022  &
1024  fopc);
1025  fopc->timeout_task =
1028  fopc);
1030  fopcq_tail,
1031  fopc);
1033  return;
1034  }
1035  LOG_DEBUG ("Received PEER_RECONFIGURE for peer %u\n",
1036  (unsigned int) peer_id);
1037  if (0 < peer->reference_cnt)
1038  {
1039  GNUNET_break (0);
1041  op_id,
1042  "Peer in use");
1044  return;
1045  }
1046  if (GNUNET_YES == peer->destroy_flag)
1047  {
1048  GNUNET_break (0);
1050  op_id,
1051  "Peer is being destroyed");
1053  return;
1054  }
1055  cfg = GNUNET_TESTBED_extract_config_ (&msg->header);
1056  if (NULL == cfg)
1057  {
1058  GNUNET_break (0);
1060  op_id,
1061  "Compression error");
1063  return;
1064  }
1065  if (GNUNET_NO == peer->details.local.is_running)
1066  {
1067  emsg = update_peer_config (peer,
1068  cfg);
1069  if (NULL != emsg)
1071  op_id,
1072  emsg);
1074  op_id);
1076  GNUNET_free (emsg);
1077  return;
1078  }
1079  prc = GNUNET_new (struct PeerReconfigureContext);
1080  if (GNUNET_OK !=
1081  GNUNET_TESTING_peer_stop_async (peer->details.local.peer,
1082  &prc_stop_cb,
1083  prc))
1084  {
1085  GNUNET_assert (0 < GNUNET_asprintf (&emsg,
1086  "Error trying to stop peer %u asynchronously\n",
1087  peer_id));
1089  "%s\n",
1090  emsg);
1092  op_id,
1093  emsg);
1095  GNUNET_free (prc);
1096  GNUNET_free (emsg);
1097  return;
1098  }
1099  prc->cfg = cfg;
1100  prc->peer_id = peer_id;
1101  prc->op_id = op_id;
1102  prc->client = client;
1104  prc_tail,
1105  prc);
1107 }
static char * update_peer_config(struct Peer *peer, struct GNUNET_CONFIGURATION_Handle *cfg)
Update peer configuration.
static void prc_stop_cb(void *cls, struct GNUNET_TESTING_Peer *p, int success)
Callback to inform whether the peer is running or stopped.
static struct PeerReconfigureContext * prc_tail
The DLL tail for the peer reconfigure list.
int GNUNET_TESTING_peer_stop_async(struct GNUNET_TESTING_Peer *peer, GNUNET_TESTING_PeerStopCallback cb, void *cb_cls)
Stop a peer asynchronously using ARM API.
Definition: testing.c:1525
uint64_t op_id
The id of the operation.
uint32_t peer_id
The id of the peer which has to be reconfigured.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle to use as the new template.

References cfg, PeerReconfigureContext::cfg, ForwardedOperationContext::client, PeerReconfigureContext::client, GNUNET_TESTBED_Peer::controller, fopcq_head, fopcq_tail, GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_TESTBED_extract_config_(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTING_peer_stop_async(), GNUNET_YES, GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_peer_list, GST_send_operation_fail_msg(), GST_send_operation_success_msg(), GST_timeout, LOG, LOG_DEBUG, msg, PeerReconfigureContext::op_id, OP_PEER_RECONFIGURE, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, peer, peer_id, PeerReconfigureContext::peer_id, prc_head, prc_stop_cb(), prc_tail, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, update_peer_config(), and VALID_PEER_ID.

Here is the call graph for this function:

◆ GST_free_mctxq()

void GST_free_mctxq ( void  )

Frees the ManageServiceContext queue.

Definition at line 1114 of file gnunet-service-testbed_peers.c.

1115 {
1116  while (NULL != mctx_head)
1118 }

References cleanup_mctx(), and mctx_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_lcf()

void GST_free_lcf ( void  )

Cleans up the queue used for forwarding link controllers requests.

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

1445 {
1446  struct LCFContext *lcf;
1447 
1448  if (NULL != lcf_head)
1449  {
1450  if (NULL != lcf_proc_task_id)
1451  {
1453  lcf_proc_task_id = NULL;
1454  }
1455  }
1456  GNUNET_assert (NULL == lcf_proc_task_id);
1457  for (lcf = lcf_head; NULL != lcf; lcf = lcf_head)
1458  {
1459  if (NULL != lcf->op)
1461  if (NULL != lcf->timeout_task)
1464  lcf_tail,
1465  lcf);
1466  GNUNET_free (lcf);
1467  }
1468 }
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:2021
Link controllers request forwarding context.
struct GNUNET_SCHEDULER_Task * timeout_task
The timeout task.
struct GNUNET_TESTBED_Operation * op
Handle for operations which are forwarded while linking controllers.

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

Referenced by shutdown_task(), and slave_status_cb().

Here is the call graph for this function:
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 398 of file gnunet-service-testbed_links.c.

399 {
400  unsigned int id;
401 
402  for (id = 0; id < route_list_size; id++)
403  if (NULL != route_list[id])
404  GNUNET_free (route_list[id]);
406  route_list = NULL;
407 }

References GNUNET_free, id, route_list, and route_list_size.

Referenced by shutdown_task().

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 }
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.
Context information to used during operations which forward the overlay connect message.
uint64_t operation_id
The id of the operation which created this context information.
struct GNUNET_SERVICE_Client * client
The client handle.
struct GNUNET_MessageHeader * orig_msg
A copy of the original overlay connect message.
enum RegisteredHostContext::RHCState state
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.

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:

◆ 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 }
struct RegisteredHostContext * rhc
Which host does this FOCC belong to?
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.

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:

◆ 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 }
static void cleanup_rocc(struct RemoteOverlayConnectCtx *rocc)
Function to cleanup RemoteOverlayConnectCtx and any associated tasks with it.

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:

◆ GST_free_prcq()

void GST_free_prcq ( void  )

Cleans up the Peer reconfigure context list.

Definition at line 881 of file gnunet-service-testbed_peers.c.

882 {
883  while (NULL != prc_head)
885 }

References cleanup_prc(), and prc_head.

Referenced by shutdown_task().

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

◆ GST_cache_init()

void GST_cache_init ( unsigned int  size)

Initializes the cache.

Parameters
sizethe size of the cache

Definition at line 212 of file gnunet-service-testbed_cache.c.

213 {
214  if (0 == size)
215  return;
216  cache_size = size;
218 }
static unsigned int cache_size
Maximum number of elements to cache.
static struct GNUNET_CONTAINER_MultiHashMap32 * cache
Hashmap to maintain cache.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.

References cache, cache_size, GNUNET_CONTAINER_multihashmap32_create(), and size.

Referenced by testbed_run().

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

◆ GST_cache_clear()

void GST_cache_clear ( void  )

Clear cache.

Definition at line 190 of file gnunet-service-testbed_cache.c.

191 {
192  if (NULL != cache)
193  {
195  NULL);
198  cache = NULL;
199  }
200  cache_size = 0;
201  cache_head = NULL;
202  cache_tail = NULL;
203 }
static int cache_clear_iterator(void *cls, uint32_t key, void *value)
Iterator over hash map entries.
static struct CacheEntry * cache_tail
DLL tail for least recently used cache entries; recently used cache items are at the tail....
static struct CacheEntry * cache_head
DLL head for least recently used cache entries; least recently used cache items are at the head.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.

References cache, cache_clear_iterator(), cache_head, cache_size, cache_tail, GNUNET_assert, GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), and GNUNET_CONTAINER_multihashmap32_size().

Referenced by shutdown_task().

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

◆ GST_cache_lookup_hello()

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.

Parameters
peer_idthe index of the peer whose HELLO has to be looked up
Returns
the HELLO message; NULL if not found

Definition at line 228 of file gnunet-service-testbed_cache.c.

229 {
230  struct CacheEntry *entry;
231 
232  LOG_DEBUG ("Looking up HELLO for peer %u\n", peer_id);
233  if (NULL == cache)
234  {
235  LOG_DEBUG ("Caching disabled\n");
236  return NULL;
237  }
238  entry = cache_lookup (peer_id);
239  if (NULL == entry)
240  return NULL;
241  if (NULL != entry->hello)
242  LOG_DEBUG ("HELLO found for peer %u\n", peer_id);
243  return entry->hello;
244 }
static struct CacheEntry * cache_lookup(unsigned int peer_id)
Looks up in the cache and returns the entry.
struct GNUNET_MessageHeader * hello
The HELLO message.

References cache, cache_lookup(), CacheEntry::hello, LOG_DEBUG, and peer_id.

Referenced by occ_cache_get_handle_core_cb().

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

◆ GST_cache_add_hello()

void GST_cache_add_hello ( const unsigned int  peer_id,
const struct GNUNET_MessageHeader hello 
)

Caches the HELLO of the given peer.

Updates the HELLO if it was already cached before

Parameters
peer_idthe peer identity of the peer whose HELLO has to be cached
hellothe HELLO message

Definition at line 255 of file gnunet-service-testbed_cache.c.

257 {
258  struct CacheEntry *entry;
259 
260  if (NULL == cache)
261  return;
262  entry = cache_lookup (peer_id);
263  if (NULL == entry)
264  entry = add_entry (peer_id);
265  GNUNET_free (entry->hello);
266  entry->hello = GNUNET_copy_message (hello);
267 }
static struct CacheEntry * add_entry(unsigned int peer_id)
Creates a new cache entry and then puts it into the cache's hashtable.

References add_entry(), cache, cache_lookup(), GNUNET_copy_message(), GNUNET_free, CacheEntry::hello, and peer_id.

Referenced by hello_update_cb().

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

◆ GST_stats_init()

void GST_stats_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize logging CPU and IO statisticfs.

Checks the configuration for "STATS_DIR" and logs to a file in that directory. The file is name is generated from the hostname and the process's PID.

Definition at line 590 of file gnunet-service-testbed_cpustatus.c.

591 {
592  char *hostname;
593  char *stats_dir;
594  char *fn;
595  size_t len;
596 
597  if (GNUNET_OK !=
599  "STATS_DIR", &stats_dir))
600  return;
603  if (0 != gethostname (hostname, len))
604  {
606  GNUNET_free (stats_dir);
608  return;
609  }
610  fn = NULL;
611  (void) GNUNET_asprintf (&fn, "%s/%.*s-%jd.dat", stats_dir, (int)len,
612  hostname, (intmax_t) getpid ());
613  GNUNET_free (stats_dir);
615  if (NULL == (bw = GNUNET_BIO_write_open_file (fn)))
616  {
618  _ ("Cannot open %s for writing load statistics. "
619  "Not logging load statistics\n"), fn);
620  GNUNET_free (fn);
621  return;
622  }
623  GNUNET_free (fn);
625 #ifdef __linux__
626  proc_stat = fopen ("/proc/stat", "r");
627  if (NULL == proc_stat)
629  "fopen", "/proc/stat");
630 #elif OSX
631  initMachCpuStats ();
632 #endif
633  updateUsage (); /* initialize */
634 }
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * hostname
Our hostname; we give this to all the peers we start.
static void sample_load_task(void *cls)
struct GNUNET_SCHEDULER_Task * sample_load_task_id
static int updateUsage()
Update the currentCPU and currentIO load (and on Linux, memory) values.
struct GNUNET_BIO_WriteHandle * bw
handle to the file to write the load statistics to
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open_file(const char *fn)
Open a file for writing.
Definition: bio.c:509
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
#define GNUNET_log(kind,...)
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
#define GNUNET_OS_get_hostname_max_length()
Get maximum string length returned by gethostname()
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:1299
#define _(String)
GNU gettext support macro.
Definition: platform.h:178

References _, bw, cfg, GNUNET_asprintf(), GNUNET_BIO_write_open_file(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror, GNUNET_log_strerror_file, GNUNET_malloc, GNUNET_OK, GNUNET_OS_get_hostname_max_length, GNUNET_SCHEDULER_add_now(), hostname, len, sample_load_task(), sample_load_task_id, and updateUsage().

Referenced by testbed_run().

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

◆ GST_stats_destroy()

void GST_stats_destroy ( void  )

Shutdown the status calls module.

Definition at line 641 of file gnunet-service-testbed_cpustatus.c.

642 {
643  if (NULL == bw)
644  return;
645 #ifdef __linux__
646  if (proc_stat != NULL)
647  {
648  fclose (proc_stat);
649  proc_stat = NULL;
650  }
651 #elif OSX
652  GNUNET_free (prev_cpu_load);
653 #endif
654  if (NULL != sample_load_task_id)
655  {
657  sample_load_task_id = NULL;
658  }
660  bw = NULL;
661 }
enum GNUNET_GenericReturnValue GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h, char **emsg)
Close an IO handle.
Definition: bio.c:557

References bw, GNUNET_BIO_write_close(), GNUNET_break, GNUNET_free, GNUNET_OK, GNUNET_SCHEDULER_cancel(), and sample_load_task_id.

Referenced by shutdown_task().

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

Variable Documentation

◆ GST_config

struct GNUNET_CONFIGURATION_Handle* GST_config
extern

Our configuration.

Definition at line 39 of file gnunet-service-testbed.c.

Referenced by handle_init(), shutdown_task(), and testbed_run().

◆ GST_context

◆ fopcq_head

◆ fopcq_tail

◆ GST_peer_list

◆ GST_host_list

◆ GST_opq_openfds

struct OperationQueue* GST_opq_openfds
extern

Operation queue for open file descriptors.

Definition at line 64 of file gnunet-service-testbed.c.

Referenced by GST_connection_pool_get_handle(), GST_neighbour_get_connection(), shutdown_task(), and testbed_run().

◆ GST_timeout

◆ GST_peer_list_size

unsigned int GST_peer_list_size
extern

◆ GST_num_local_peers

unsigned int GST_num_local_peers
extern

The current number of peers running locally under this controller.

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

Referenced by peer_list_add(), and peer_list_remove().

◆ GST_host_list_size

unsigned int GST_host_list_size
extern

The size of the host list.

Definition at line 74 of file gnunet-service-testbed.c.

Referenced by handle_link_controllers(), host_list_add(), and shutdown_task().

◆ GST_stats_dir

char* GST_stats_dir
extern

The directory where to store load statistics data.